caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Hezekiah M. Carty" <hcarty@atmos.umd.edu>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unset or remove an OCaml callback registration
Date: Thu, 3 Apr 2008 10:07:48 -0400	[thread overview]
Message-ID: <20080403140748.GA5408@fry> (raw)
In-Reply-To: <20080403.092612.89121596.garrigue@math.nagoya-u.ac.jp>

On Thu, 03 Apr 2008, Jacques Garrigue wrote:

> From: "Hezekiah M. Carty" <hcarty@atmos.umd.edu>
> > Is this possible, either from the C or OCaml side without making the
> > callback associate with "foo" an option type (use (Callback.register
> > "foo" (Some some_func)) to set a callback and (Callback.register "foo"
> > None) to clear it)?
> 
> Since Callback.register has type: string -> 'a -> unit
> you are not limited by the ocaml type system.
> So you can reset your value with
>   Callback.register "foo" 0
> and check for equality with Val_int(0) on the C side.
> (Note that you must initialize the value to 0 at program startup,
> because the default for an unitialized value is 0 which is not
> Val_int(0))

If I wrap the C interface in an OCaml module, would it be enough to
include:

let () = Callback.register "foo" 0

in the top level of the module to have this command execute when the
module is loaded?  Or does the module user have to do some explicit
initialization?

Thank you very much for the response,
Hez


  reply	other threads:[~2008-04-03 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-02 18:12 Hezekiah M. Carty
2008-04-03  0:26 ` [Caml-list] " Jacques Garrigue
2008-04-03 14:07   ` Hezekiah M. Carty [this message]
2008-04-03 14:25     ` Gordon Henriksen

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=20080403140748.GA5408@fry \
    --to=hcarty@atmos.umd.edu \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).