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
Metaprogramming features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chung-chieh Shan <ccshan@p...>
Subject: Re: Metaprogramming features
Jon Harrop <> wrote in article <> in gmane.comp.lang.caml.inria:
> On Monday 06 October 2008 15:06:12 you wrote:
> > I'm definitely missing something here.  How are the above examples
> > different from:
> > let f () = 1 + 2;;
> > f ();;
> > let f x = 1 + x;;
> >
> > ?
> >
> > This is a non-trivial question, as there is no clear delineation between
> > data structures and executable code.

Indeed the question is not trivial.  Because MetaOCaml (like OCaml) has
higher-order functions (which may operate on code values or on functions
on code values), it is not trivial at all to `simulate' MetaOCaml in
OCaml.  Our PEPM paper this year (Kameyama, Kiselyov, and Shan) needed
the full power of System F just to express a subset of MetaOCaml without
polymorphism (even let-bound) or nested quotation (such as .<.<42>.>.).

Section 2 of this paper gives a series of examples to illustrate the
non-triviality of the simulation.  You can try to skip to Section 2.5
to see the most challenging example there.

> Exactly. The difference is (only) the performance characteristics.

To the contrary, that is not the only difference; the timing of
side effects (including non-termination and exceptions) can also be
different.  We give an example at the beginning of our Section 2.

Edit this signature at
2008-10-01 International Day of Older Persons
2008-11-20 Universal Children's Day
2008-11-25 Day for the Elimination of Violence Against Women
1948-12-10 Universal Declaration of Human Rights