JOSEPH RYAN writes:
> As bad of an idea that I think this is, I wonder if Perl6's reflection
> capabilities will be powerful enough to where a module/pragma could be
> written that would be able to do this?  For instance, one idea was:
> lexically change the current grammar to a subclass of the grammar.  In
> this subclass, there is a hook on the "variable" deparsing rule that
> will implictly declare a variable into its outer scope if it has not
> yet been declared in the current scope.  Totally whacky, sure; but
> doable?

I don't doubt it.  I'd write it right now, but we don't know enough
about the compiler interface yet.

> That brings up another idea that I had just now: will it be possible
> to load 2 different grammars at once if they don't conflict with each
> other?  For instance, say we have loaded a grammer,
> Grammar::WhackyVars, that subclasses from the main Perl6 grammar but
> modifies the "variable" rule somehow.  However, then say I want to use
> a grammar that also subclasses from the main Perl6 grammar that lets
> you use "happyfunactiontime" instead of the word "class".  Since the
> modified rules don't conflict with each other, can I just "use
> Grammar::HappyFunActionTime" and everything will work?  Or will
> Grammar::HappyFunActionTime overload the changes done by the
> Grammar::WhackyVars?

This begs the use of a particular abstraction Perl 6 has introduced with
grammars.  Maybe grammar munges aren't subclasses at all, but
grammatical roles. 

The only problem I see with such roles is code generation.  If we're
going to make it parse in such a modular way, we ought to generate code
in the same modular way.  That will take some clever design (but I think
it can be done).  This is important insight right about now, since we're
rethinking what the parse tree that rules spit out looks like.

Luke

Reply via email to