From: William Lovas <wlovas@stwing.upenn.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] undocumented external ... = "%identity"
Date: Fri, 31 Oct 2003 02:47:48 -0500 [thread overview]
Message-ID: <20031031074747.GA29233@force.stwing.upenn.edu> (raw)
In-Reply-To: <20031030195548.GD19967@fistandantilus.takhisis.org>
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
next prev parent reply other threads:[~2003-10-31 7:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-29 10:42 Stefano Zacchiroli
2003-10-29 11:39 ` Jacques Garrigue
2003-10-30 19:55 ` Stefano Zacchiroli
2003-10-31 7:47 ` William Lovas [this message]
2003-11-01 8:22 ` Stefano Zacchiroli
2003-11-03 14:03 ` Damien Doligez
2003-11-03 14:20 ` Nicolas Cannasse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031031074747.GA29233@force.stwing.upenn.edu \
--to=wlovas@stwing.upenn.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox