[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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.
Jacques
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners