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
Obj.dup crash ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-30 (11:03)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Obj.dup crash ?
> Concerning Obj.dup, I guess it is never actually called when the block
> has 0 fields. Actually, where is Obj.dup used except in
> CamlinternalOO.copy ?  Quick look. It is used in the code generator:
> for array constants of size > 4, and for record expressions { ... with
> ... } that copy the original record and then modify it (but the empty
> record is not a valid type !). So indeed, it seems that Obj.dup is never
> called for 0 fields blocks. The implementation has dead code, but
> it is not buggy ;-)

It's also used in ExtLib DynArray when copying an array ;)
I understand that Obj is an undocumented/unspecified module but it should at
least work as expected.
Is there a particular reason for 0 fields blocks not being allocated ?
Actually Obj.tag (Obj.new_block 0 0) returns 500 which is not really the
expected result.

> but the empty record is not a valid type

It can't be parsed using default caml syntax but it surely can be
represented into the AST since I expect it to be a "something list". Now I'm
not sure such a type would pass the type checker or even how you're supposed
to instanciate it :)

Having 0 fields blocks might be useful for high level language features that
want to use OCaml as their runtime system, because of its very good native

Nicolas Cannasse