Version française
Home     About     Download     Resources     Contact us    
Browse thread
anonymous function + lable bug?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven LUTHER <luther@d...>
Subject: Re: anonymous function + lable bug?
On Sun, Nov 05, 2000 at 05:11:11AM -0800, Chris Hecker wrote:
> 
> Is this a bug?
> 
> # let f = fun ~x -> x;;
> val f : x:'a -> 'a = <fun>
> 
> # let g = function ~x -> x;;
> Characters 17-18:
> Syntax error
> 
> I thought these two were equivalent?

No, function has only one argument, and can do more kind of polymorphism than 
fun which can take more than one argument as in :

let f = fun x y z -> x + y + z
f 5 6 7 evaluates to 18.

I think the use of function is preferable over fun, which is there for
compatibility reasons.

not sure what the ~ does, i think it is one of the label stuffs.

Try :

# let f ~x = x ;;
val f : x:'a -> 'a = <fun>

Don't know why there is a problem with the above though.

Friendly,

Sven Luther