English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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-19 (08:58)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Unboxing options, was RE: assertions or exceptions?
On Jul 16, 2004, at 18:40, Xavier Leroy wrote:

>>> The idea is just to reserve a sufficiently large memory area to
>>> represent every needed (Some (Some ...(Some None) ...)).
>> Caml's internal pointers are at minimum 4-byte aligned.  What about
>> using the other "safe" set of trailing bits, "10", to mark options?
>> i.e.:
>> None = ...0010 (2)
>> Some None =  ...0110 (6)
> This is very tempting indeed, but the Caml heap compactor already uses
> the ...10 encoding to temporarily mark some data during compaction.

Unless I am badly mistaken, the compactor already has to deal with
such values (as out-of-heap pointers) and has no problem with them.

However, this is almost the same as Jacques' description, because
you still have to make sure that these special values point to some
area of memory where nothing will ever be allocated.

Finally, Jacques was not quite right in asserting that most options
are short-lived.  This is only true if you don't use "option" in your
main long-lived data structure.  Most seasoned OCaml programmers know
it, and sometimes it leads to rather contorted data structures.

> As Jacques said, we've toyed with the idea of encoding option types
> specially for quite a while, and even prototyped it at some point, but
> never got convinced that it was really important to do so.

It is still bothering me, at least.

-- Damien

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