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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Karl Zilles <zilles@1...>
Subject: Re: [Caml-list] Unboxing options, was RE: assertions or exceptions?
John Carr wrote:

> [None represented internally as 0]
> 
> 
>>What's the representation of Some(None) then?  The Some() goes away, and 
>>the containing value is unboxed- it turns out to be the same as just None.  
>>There is no way to differentiate Some(Some(Some(Some(None)))) from None.
> 
> 
> There is also no way to distinguish 0 from None in the current
> system.  OCaml relies on type information to determine the meaning
> of a value.

0 and None are different types.  There is no need to distinguish them.

> 
> Is there valid code (no Obj.magic) that cares that (Some None) and
> (None) are both represented by the same bit pattern?

(Some None) and (None) are both the same type: a' option option

Valid code:

match x with
| Some a -> printf "Some!"
| None -> printf "None!"

(Some None) should print Some!, (None) should print None!, but since the 
bit patterns are now the same...



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