caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Camlp4: syntax extension in source file
@ 2002-10-24 22:33 Alain Frisch
  2002-10-25  9:39 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 2+ messages in thread
From: Alain Frisch @ 2002-10-24 22:33 UTC (permalink / raw)
  To: Caml list

Hello,

This thread about macro definition with Camlp4 reminds me of an idea I had
some time ago. The idea is to use the Toplevel lib to introduce Caml
syntax extension directly inside source file. Something like that:


SYNTAX
  let x = ....

  EXTEND
    expr: [ .... ];
  END
END


The code between SYNTAX and END is parsed, compiled and executed by Camp4
during the preprocessing phase; it modifies the syntax used to parsed the
remaining of the rest of the file (including perhaps following SYNTAX ...
END statements). This allows a limited kind of reflexivity:  the source
file describes its own syntax. It also gives the possibility to perform
some computations at compile time (the "x" above).


I cannot remember why I didn't succeed to make it work (I think I had
some problems because of limitations in what the toplevel library
exports).

Daniel - and others - do you believe the above proposition makes sense ?


-- Alain

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Camlp4: syntax extension in source file
  2002-10-24 22:33 [Caml-list] Camlp4: syntax extension in source file Alain Frisch
@ 2002-10-25  9:39 ` Daniel de Rauglaudre
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-25  9:39 UTC (permalink / raw)
  To: caml-list

Hi,

On Fri, Oct 25, 2002 at 12:33:48AM +0200, Alain Frisch wrote:
> 
> This thread about macro definition with Camlp4 reminds me of an idea I had
> some time ago. The idea is to use the Toplevel lib to introduce Caml
> syntax extension directly inside source file.

Introducing the equivalent of "eval"? This is an old idea, indeed.

For the moment, loading the OCaml toplevel does not work:
     $ camlp4r -I `ocamlc -where` toplevellib.cma
     Error while loading "lib/ocaml/toplevellib.cma":
       no implementation available for Outcometree

It is because of the module Dynlink which is too severe for interfaces
not having implementations.

Too severe, probably, and anyway more severe than the linker. Compare
the functions "check_consistency" of:

   1/ otherlibs/dynlink/dynlink.ml and
   2/ bytecomp/bytelink.ml

In the case "Not_found", Dynlink refuses while Bytelink accepts.
Changing this case in the Dynlink module make the loading work.

The next step is to know if it is possible to extract a good "eval"
function from the modules Toploop or Topdir. I am not sure.

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-25  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24 22:33 [Caml-list] Camlp4: syntax extension in source file Alain Frisch
2002-10-25  9:39 ` Daniel de Rauglaudre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).