So I ended up with something like this --- Callbacks.ml
type t type 'a callback = | Alert of ('a -> Alert.t -> unit) | AskQuote of ('a -> Ask.t -> unit) | BestAskQuote of ('a -> Ask.t -> unit) | BidQuote of ('a -> Bid.t -> unit) | BestBidQuote of ('a -> Bid.t -> unit) | ClosePrice of ('a -> ClosePrice.t -> unit) | ClosingIndicator of ('a -> ClosingIndicator.t -> unit) | EndQuote of of ('a -> EndQuote.t -> unit) | EquityOptionList of of ('a -> EquityOptionList.t -> unit) | EquityOptionStrategyList of of ('a -> EquityOptionStrategyList.t -> unit) | HighPrice of ('a -> HighPrice.t -> unit) | Indicator of ('a -> Indicator.t -> unit) | IndicatorReplay of ('a -> IndicatorReplay.t -> unit) | LimitOrderBook of ('a -> LimitOrderBook.t -> unit) | LowPrice of ('a -> LowPrice.t -> unit) | MarketMode of ('a -> MarketMode.t -> unit) | OpenPrice of ('a -> OpenPrice.t -> unit) ... external make : unit -> t = "Callbacks_new" external set : t -> 'a callback -> unit = "Callbacks_set" I now want to grab the closure from the constructor on the C side and stick it into a callback array. Is this sufficient? extern "C" CAMLprim value Callbacks_set(value v) { CAMLparam1(v); int i = Tag_val(v); CAMLlocal1(f); f = Field(0, v); caml_register_global_root(f); callbacks[i] = f; CAMLreturn(Val_unit); } Thanks, Joel -------------------------------------------------------------------------- Working on AlgoKit, a new algorithmic trading platform using Rithmic R|API ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs