Larry Wall wrote:
> Well, only if you stick to a standard dialect.  As soon as you start
> defining your own macros, it gets a little trickier.

Interesting, I hadn't considered that.

Having a quick browse through some of the discussions about macros, many
of the macros I saw[*] looked something like they could be conceptualised
as referring to the part of the AST where they were defined.

ie, making the AST more of an Abstract Syntax Graph.  And macros like
'free' (ie, stack frame and scope-less) subs, with only the complication
of variable binding.  The ability to have recursive macros would then
relate to this graph-ness.

What are the shortcomings of this view of macros, as 'smart' (symbol
binding) AST shortcuts?

The ability to know exactly what source corresponds to a given point on
the AST, as well as knowing straight after parse time (save for string
eval, of course) what each token in the source stream relates to is one
thing that I'm aiming to have work with Perldoc.  I'm hoping this will
assist I18N efforts and other uses like smart editors.

By smart editors, I'm talking about something that uses Perl/PPI as its
grammar parsing engine, and it highlights the code based on where each
token in the source stream ended up on the AST.  This would work
completely with source that munges grammars (assuming the grammars are
working ;).  Then, use cases like performing L10N for display to non-
English speakers would be 'easy'.  I can think of other side-benefits
to such "regularity" of the language, such as allowing Programatica-
style systems for visually identifying 'proof-carrying code' and
'testing certificates' (see http://xrl.us/programatica).

macros that run at compile time, and insert strings back into the
document source seem hackish and scary to these sorts of prospects.
But then, one man's hackish and scary is another man's elegant
simplicity, I guess.

* - in particular, messages like this:
    - http://xrl.us/fr78

    but this one gives me a hint that there is more to the story... I
    don't grok the intent of 'is parsed'
    - http://xrl.us/fr8a

Reply via email to