caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* A macro system compatible with modules
@ 2007-06-20 12:17 Loup Vaillant
  2007-06-20 12:52 ` [Caml-list] " Pietro Abate
  0 siblings, 1 reply; 2+ messages in thread
From: Loup Vaillant @ 2007-06-20 12:17 UTC (permalink / raw)
  To: Caml List

Hello,

I would like to define a macro system (like #define) which satisfy the
following constraints :

-> When I define a macro, it is available for use right now, in the
same compilation unit.
-> If I want to call the macro from another compilation unit, I just
have to either open the corresponding module :

open My_comp_unit;;
(* some code *)
my_macro (* macro arguments *)

or access the macro through indirection :

My_comp_unit.my_macro (* macro arguments *)

-> [optional] a macro must declared in the .mli file to be accessible
from the outside, and is automatically accessible if this .mli file is
not defined by the author of the compilation unit.
-> [optional] do the same things for any module (defined as is, or
from a functor)

This would be ideal for avoiding namespaces issues.

What about plain camlp4 macros?
What about the #define defined in camlp4?
Is such a a thing possible?
To what extent?

Thanks,
Loup Vaillant

(reminder
  my ultimate goal is Lisp-like macros)


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

* Re: [Caml-list] A macro system compatible with modules
  2007-06-20 12:17 A macro system compatible with modules Loup Vaillant
@ 2007-06-20 12:52 ` Pietro Abate
  0 siblings, 0 replies; 2+ messages in thread
From: Pietro Abate @ 2007-06-20 12:52 UTC (permalink / raw)
  To: caml-list, Caml List

On Wed, Jun 20, 2007 at 02:17:22PM +0200, Loup Vaillant wrote:
> -> When I define a macro, it is available for use right now, in the
> same compilation unit.
> -> If I want to call the macro from another compilation unit, I just
> have to either open the corresponding module :

I've written something similar for one of my projects.
http://twb.rsise.anu.edu.au/simple_syntax_extension

I think you can use the same technique to generate a define statement
that can be used straight away in your module and eventually export
to other modules.

pietro


-- 
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html


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

end of thread, other threads:[~2007-06-20 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-20 12:17 A macro system compatible with modules Loup Vaillant
2007-06-20 12:52 ` [Caml-list] " Pietro Abate

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