caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Maas-Maarten Zeeman <maas@wanadoo.nl>
To: Harry Chomsky <harry@chomsky.net>
Cc: Damien Doligez <Damien.Doligez@inria.fr>,
	Chris Hecker <checker@d6.com>,
	"Mary F. Fernandez" <mff@research.att.com>,
	caml-list@inria.fr, Jerome Simeon <simeon@research.bell-labs.com>
Subject: Re: [Caml-list] Question about register_global_root
Date: Mon, 02 Jun 2003 22:02:01 +0200	[thread overview]
Message-ID: <3EDBAD39.2040901@wanadoo.nl> (raw)
In-Reply-To: <004601c32923$0269fb00$0200a8c0@harry>

Harry Chomsky wrote:

>Damien Doligez wrote:
>  
>
>>On Sunday, June 1, 2003, at 12:50 PM, Maas-Maarten Zeeman wrote:
>>    
>>
>>>The manual explicitly tells that register_global_root should be called
>>>before any valid value is stored in it for the first time, like
>>>Val_unit. See Rule 4 of Interfacing C with Objective Caml in the
>>>manual.
>>>      
>>>
>>I'm afraid Chris is right and the manual is wrong.
>>[...]
>>You must store a valid value before the first allocation that follows
>>register_global_root.
>>    
>>
>
>I think that both Chris and the manual are right.  The manual actually
>instructs the programmer to register a global root v "just before a valid
>value is stored in v for the first time".  Key word: "just".  In other
>words, as Damien says, no allocations are allowed between registration and
>storing a value.
>
>Apparently more than one reader of the manual has missed this detail.  Would
>it be clearer to say "immediately before" instead of "just before"?
>  
>
Maybe it is better to be even more explicit.

Registration of a global variable v is achieved by calling 
register_global_root(&v), with v initialized to Val_unit, before 
allocating and storing a valid value in v for the first time.

On the other hand, some ocaml libraries (which are also examples) which 
use register_global_root, do not always follow this rule. i.e. 
install_signal_handler uses it like this:

  signal_handlers = alloc(NSIG, 0);
  register_global_root(&signal_handlers);

Is this also allowed?

All this also raises a question about the remove_global_root call, are 
there any special precautions I need to take just before or just after 
calling remove_global_root? Or can it be called at any time?

Maas


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


  reply	other threads:[~2003-06-02 20:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-28 19:45 Mary F. Fernandez
2003-05-28 19:51 ` Alexander V. Voinov
2003-05-28 20:33 ` Maas-Maarten Zeeman
2003-05-29  1:31   ` Jerome Simeon
2003-06-01  7:24   ` Chris Hecker
2003-06-01 10:50     ` Maas-Maarten Zeeman
2003-06-01 11:10       ` Chris Hecker
2003-06-01 19:53       ` Damien Doligez
2003-06-02 11:37         ` Jerome Simeon
2003-06-02 12:11           ` Maas-Maarten Zeeman
2003-06-02 12:19             ` [Caml-list] Am I mad?: OCaml for scientific scripting Siegfried Gonzi
2003-06-02 12:21             ` Siegfried Gonzi
2003-06-02 16:21         ` [Caml-list] Question about register_global_root Harry Chomsky
2003-06-02 20:02           ` Maas-Maarten Zeeman [this message]
2003-06-03  0:05             ` Chris Hecker
2003-06-01 19:19 ` Florian Douetteau

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=3EDBAD39.2040901@wanadoo.nl \
    --to=maas@wanadoo.nl \
    --cc=Damien.Doligez@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=checker@d6.com \
    --cc=harry@chomsky.net \
    --cc=mff@research.att.com \
    --cc=simeon@research.bell-labs.com \
    /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;
as well as URLs for NNTP newsgroup(s).