Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Adding class initializers with camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-10-10 (12:26)
From: Nicolas Pouillard <nicolas.pouillard@i...>
Subject: Re: [Caml-list] Adding class initializers with camlp4
Excerpts from joelr1's message of Tue Oct 09 12:56:14 +0200 2007:
> Does anyone have examples of how to add initializer code to a class  
> via camlp4?

An  object  initializer  is a `class structure item' that can be created using
this quotation: <:class_str_item< initializer $e$ >> these initializers can be
used in a object structure in an expression or class
<:expr< object $class_str_item$ end >>.

> It's not clear to me how one can extend the list of existing  
> initializers, for example. There may be some or there may be none.  
> Same thing with fields.

The  list  is not explicit, however you can easily extend them on the front or
the back.

<:class_expr< object ($p$) $cstr$ end >> ->
  <:class_expr< object ($p$) initializer $e1$; $cst$; initializer $e2$ >>


Nicolas Pouillard aka Ertai