Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: A Macro System for Perl?

by samtregar (Abbot)
on May 04, 2002 at 06:45 UTC ( #163972=note: print w/ replies, xml ) Need Help??


in reply to Re: A Macro System for Perl?
in thread A Macro System for Perl?

The thread started interesting, but it died out well before getting to a useful design. It didn't sound to me like any of the key architects (Dan Sugaliki, for example) are taking building a macro system particularily serriously.

-sam


Comment on Re: Re: A Macro System for Perl?
Re: Re: Re: A Macro System for Perl?
by Elian (Parson) on May 04, 2002 at 13:38 UTC
    Good grief--you can do a full text transform on the source before the parser gets it, and we're giving you access to the AST to do a full symbolic transform on before it's passed on to the compiler. You can add new tokens to the parser, change the meaning of existing tokens, add new code generation for new tokens to the compiler, and change the output from the compiler for existing tokens. How much more do you want?
      None of these nice things (straight text transform, AST manipulation, adding tokens to the parser) add up to a full macro system. They will be useful tools in building a macro system but without a design we just won't get there. That's what this meditation is about, and frankly I have to mark it a failure. I guess no one out there has any clearer ideas than I do about what a macro system for Perl should look like!

      -sam

        You really need to answer the question "What will I do with the macro system" before you have any hope of a design.

        Some things, like the compile-time text transformation that C's preprocessor does, is best done with source filters, and at this point is both doable and pretty simple.

        Fancier things, like adding new syntax (such as the switch statement or whatever) are best done by actually adding new syntax to the parser and compiler, putting it outside the realm of macros.

        You might want to go ahead and mess with tokens--for example changing the definition of + for a lexical scope, but that's best done either by a change to the parser (and thus a change to the underlying language) or a change to the compiler's rules for tokens, both of which are best done in either the parser grammar language or by adding a few regexes and rules to the compiler. (Which, I suppose, could be considered macros of a sort, though I wouldn't)

        So what do you want to do with the macros? Until you answer that, there's not much to be done to design the things.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://163972]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2014-09-21 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls