Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-07-15 (21:13)
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 Archives:
Bug reports: FAQ:
Beginner's list: