Err, right, sorry. If you have None in, say, a record, that's not allocated at all. Rather than there being a pointer in that field, there is special word in that field which represents None. If that field is a Some, then it's a pointer to a two word allocated block which in turn points at the actual thing. So compared to a C pointer, there an extra two words and one more indirection. On 17 January 2014 08:16, Julien Blond wrote: > > An option value always takes two words: one for the header, and then > either a pointer or a word that means "None". > > No. From the reference manual § 19.3.4 : > > type 'a option = None (* Val_int(0), i.e. just an integer value > = 1 word *) > | Some of 'a (* block of size 1 = [(header = 1 > word) + (1 field = 1 word)] = 2 words *) > > > 2014/1/17 David House > >> It behaves identically to that type. >> >> It is just like any other sum type. However, due to the way that sum >> types are represented in memory, it is not that inefficient. The only thing >> that makes it less efficient than a C pointer is the header block >> (necessary for the GC). An option value always takes two words: one for the >> header, and then either a pointer or a word that means "None". >> >> >> On 17 January 2014 07:35, Damien Guichard wrote: >> >>> Hello, >>> >>> Compared to the code : >>> >>> type 'a option = None | Some of 'a >>> >>> How do an 'a option value performs ? >>> Any allocation saved ? >>> Any indirection removed ? >>> >>> Is 'a option just like any sum type ? >>> Or is 'a option more like an ANSI C pointer type ? >>> >>> Regards, >>> >>> Damien Guichard >>> >>> >>> >>> -- >>> Caml-list mailing list. Subscription management and archives: >>> https://sympa.inria.fr/sympa/arc/caml-list >>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>> Bug reports: http://caml.inria.fr/bin/caml-bugs >>> >> >> >