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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frederic van der Plancke <fvdp@d...>
Subject: Re: [Caml-list] Stupid question


Hendrik Tews wrote:
> 
> Brian Hurt writes:
> 
>    OK.  This makes more sense.  Well, except for the nitpicking detail that
>    true and false are not valid variant type identifiers, they should be True
>    and False.
> 
> There is a special exception: true, false, [], (), and :: are
> constructor names, see 6.3 Naming objects. One can ideed write
> 
> # type x = true of int | () of string | :: of float

But you better have a pair of types after '::' ;-)

# let x = true 123;;
val x : x = true 123
# let y = () "eh eh";;
val y : x = () "eh eh"
# let z = :: 1.5;;
Toplevel input:
# let z = :: 1.5;;
          ^^
Syntax error
# let z = 1.5 ::;;
Toplevel input:
# let z = 1.5 ::;;
                ^^
Syntax error
# let z = 1.5 :: 1.5;;
Toplevel input:
# let z = 1.5 :: 1.5;;
          ^^^^^^^^^^
This expression has type float * float but is here used with type float

Frédéric vdP

-------------------
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