English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Even at compile time 2*2=4!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-19 (18:09)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] Even at compile time 2*2=4!
On Tue, Nov 19, 2002 at 12:12:01PM +0100, Daniel de Rauglaudre wrote:

> In some cases, you could resolve your problem with Camlp4, if your
> computation can be done at parse time. We can imagine a syntax
> extension, e.g. "compute" followed by an expression, ask the
> preprocessor to evalutate it and build the syntax tree of the
> result. For example:
>     compute (2*2)
> would generate at parse time:
>     4
> But this could not work:
>     let x = 2 in
>     compute(x*x)
> because the preprocessor does not know what is "x".

To be useful, you would probably also have to be able to define
functions for the preprocessor that could be used to compute the value.

This also makes the interesting possibility of compiles that don't

      compute (forever ())

Dave Brown
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