in reply to Re: lexicaly scoped export of variables?
in thread lexicaly scoped export of variables?

Thanks a lot, thats fascinating.

I can't put too much dependencies into it so I approached it with PadWalker. (see next post)

But looking into your approach, I'd like to know if it's possible to hook into the parser to implement a macro mechanism like this.

Like:

a) parse call-statements like my_call(1,2,3)

b) check if sub my_call is a macro

c) if no continue as usual and create entersub opcode

d) if yes execute macro my_call with parsed parameters as strings exp('1','2','3')

e) inject returned string as code

f) continue with next statement

Is this feasible??? :)

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^3: lexicaly scoped export of variables? (macro)
by tobyink (Canon) on Mar 31, 2014 at 21:55 UTC

    "I'd like to know if it's possible to hook into the parser to implement a macro mechanism like this."

    You know, I was thinking something similar myself. Personally I'd do it with Parse::Keyword/Keyword::Simple.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      > Keyword::Simple

      You know, I met Lukas last week... :)

      This looks already pretty close, awesome!

      Pity we didn't have more time to talk.

      Cheers Rolf

      ( addicted to the Perl Programming Language)