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
[Caml-list] partial eval question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-27 (20:08)
From: Jacques Carette <carette@m...>
Subject: RE: [Caml-list] partial eval question
> If you really want more control over code generation (not forgetting
> that just writing out what you want by hand is often the simplest
> option in practice!) then I think C++ templates are a dead end---far
> better to make the object language the same as the target language,
> as in MetaOcaml and similar.

If you know what you want, MetaOcaml is great.  If you are
prototyping/experimenting, then a typeless symbolic language (like Scheme or
Maple) give you much greater flexibility.  MetaOcaml's contortions to get
something like:

> pow := proc(x,n::nonnegint) if n=0 then 1 else times(x,pow(x,n-1)) end if
end proc;
pow := proc(x, n::nonnegint)
    if n = 0 then 1 else times(x, pow(x, n - 1)) end if
end proc

> unapply(pow(x,5), x);
       x -> times(x, times(x, times(x, times(x, times(x, 1)))))

is really quite burdensome.  Having the freedom of dealing with 'open' terms
as first-class citizens is really very powerful, if somewhat dangerous.

I have found Thiemann's PGG as the 'front end', coupled with
Scheme-to-YourFavoriteLanguage translation to be quite effective PE
strategy, at least when more basic 'symbolic computation' is not enough.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: