[mercury-users] lisp macros
Ralph Becket
rafe at cs.mu.OZ.AU
Wed May 29 16:18:40 AEST 2002
Michael Day, Wednesday, 29 May 2002:
>
> > One could imagine some sort of Mercury pre-processing library in which
> > Mercury pre-processors could be written. For example, a preprocessor
> > compiled for a rule like
> >
> > :- macro pred_lambda (test(X) :- Body)
> > == (pred(X::in) is semidet :- Body).
>
> Would it be powerful enough to express a parser generator like moose?
> (Which would require reading all the :- rule declarations in a module to
> build a number of global tables).
My guess is that any scheme like this would have to be provided with
access to "mostly" parsed Mercury, in which it would be possible to at
least identify goals, declarations, expressions and so forth and,
possibly, identification of variables local to a goal or expression.
One would also want the ability to introduce new auxiliary predicates.
As for being powerful enough to do the job of Moose, I'd imagine so.
> > [I suppose there's no need for a separate pre-processor - this could be
> > integrated into the compiler, but if you want to allow some kind of
> > processing in producing the expansions then things might get
> > trickier... On the other hand, if pre-processor A produces macros
> > expanded by pre-processor B and vice versa, then it isn't clear what the
> > policy should be. Perhaps this sort of thing should be forbidden.]
>
> Ordering of pre-processing steps also needs to be specified, presumably.
> Or it just runs each one and repeats until no further expansions are
> produced?
This is one of the things that would have to be considered.
> > I'm not making any claims that this would be a great thing, however.
> > I'm undecided. Part of me is thinking that light-weight higher-order
> > syntax and support for monadic style would go a long way.
>
> Light weight higher order syntax would certainly be nice if it's possible.
Where straightforward composition and combination falls down is the
situations where you end up writing the same bit of meta-boilerplate
(e.g. type, mode and determinism declarations) all over the place.
Writing pred lambdas is really painful in the current syntax. Tom
Conway's xml parser is a good illustration of my point.
- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list