Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] labels in records?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] labels in records?
On Fri, 7 Nov 2003, Chris GauthierDickey wrote:

> Is it possible to use a labelled function as a member of a record?
> 
> In other words:
> 
> let f ~x = x + 1
> 
> type { g: ~x:int -> int }
>                ^
>          syntax error

No tilde.  Try:
type t = { g: x:int -> int }

One nice thing about ocaml, is that the top level prints out 
syntax-correct types.  So, you see: 

# let f ~x = x + 3 ;;
val f : x:int -> int = <fun>
#

Note that lack of a tilde on the type definition.  I just mention this 
because it's how *I* remember when a tilde is needed and when it isn't 
:-).

Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners