Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] undocumented external ... = "%identity"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William Lovas <wlovas@s...>
Subject: Re: [Caml-list] undocumented external ... = "%identity"
On Thu, Oct 30, 2003 at 08:55:48PM +0100, Stefano Zacchiroli wrote:
> On Wed, Oct 29, 2003 at 08:39:35PM +0900, Jacques Garrigue wrote:
> > I suppose that as Obj.magic is not documented, this is not documented
> > either. 
> 
> Ok, thanks for your answer.
> 
> Now, let me restate my question: whi obj.magic _and_ "%identity" are not
> documented? Usually undocumented stuff is stuff subject to changes, not
> stable, ecc ...

Obj.magic's "behavior" *is* subject to change, since it depends upon the
underlying representation of values.  The Obj module's documentation is,
in a very real sense, the entire implementation of the O'Caml compiler and
runtime.

> Practically, a lot of people use Obj.magic when needed and it seems to
> be part of the required knowledge to be a "discriminating hacker"(TM).
> The reason that it's unsafe and can make your program crash, IMO, is not
> a good reason not to have it documented. Indeed C interfacing APIs are
> documented and they are as risky as using Obj.magic and friends.

It's a little more than just unsafe -- when you use the Obj module, your
program becomes dependent upon the implementation of O'Caml.

Also, while it's true that interacting with C code is just as unsafe as
using the Obj module, interacting with C code is also a lot *harder* than
using the Obj module.  Presumably, if one understands how to interface
O'Caml with C, they're aware of the risks and will exercise sufficient
care.  Even a seasoned hacker's careless use of Obj.magic can go awry, as
seen in the recent thread about IEEE floating point equality.

To be fair, David Monniaux posted a message once explaining when Obj.magic
is "okay" to use:

    http://pauillac.inria.fr/caml/caml-list/0975.html

Such "okay" uses are sufficiently bizarre, though, that it makes sense to
leave the Obj module undocumented -- anyone who needs it will already
understand how it works.

cheers,
William

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