Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: A Macro System for Perl?

by Elian (Parson)
on May 03, 2002 at 19:56 UTC ( #163886=note: print w/replies, xml ) Need Help??

in reply to A Macro System for Perl?

Doing a macro system for perl could be rather interesting, as its syntax is significantly more complex than lisp's syntax. I can think of a couple of things, though:
  1. Have an inline tag to inline subs. Not, mind, that this will necessarily buy much, as perl's tough to optimize.
  2. Curried functions. No, wait, we're getting those already
  3. Substitutions at the token/AST level. This is trickier, but the regex engine in Perl 6 should be up to it.

Replies are listed 'Best First'.
Re: Re: A Macro System for Perl?
by samtregar (Abbot) on May 04, 2002 at 02:11 UTC
    I think #1 could potentially buy you quite a bit. Subroutine overhead in Perl is quite large - lots of stack operations resulting in lots of memory reads and writes. I also think this is probably the one that might be possible in Perl 5. At the core it seems that it would require nothing worse than some really clever op-tree gymnastics...

    I'm not smart enough to understand #2 yet. Someone needs to write the currying section in Learning Perl before I can grok it, perhaps.

    What do you mean by #3? Filter?


      Well, subroutine calling should be a lot cheaper in perl 6, so there ought not be much difference between starting a new block and starting a subroutine. (That's the plan, at least. Whether we can pull it off is another question entirely)

      As for #3.... the AST that the parser builds up will be accessible in some fashion, so the sort of macro transformation you have in mind could work on that, basically working on your parsed code as a series of symbols rather than as a series of characters, which'd make the transformation conceptually simpler.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://163886]
[Corion]: Yay. Traditional finance situation averted. Bonds can be quoted in amounts (1_000_000 EUR) or per unit (1 unit). And a traditional error is to trade 2_000_000 piece when you meant to trade 2_000_000 EUR.
[Corion]: (one of my scripts simply catches high amounts and I phone people making that trade, ideally before the payment is due)
[Corion]: The sad thing is that my script sits at the end of the pipeline and can only look at the payments due today or tomorrow basically, while there are many more systems further up in the pipeline
[GotToBTru]: better late than never, I guess
[Corion]: GotToBTru: Sure - there is a long and sad story of many frantic cleanups that led us to implement this notification ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-03-29 11:32 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (347 votes). Check out past polls.