Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: Re^2: NO PERL 6

by jryan (Vicar)
on Dec 10, 2002 at 21:30 UTC ( #218919=note: print w/replies, xml ) Need Help??

in reply to Re: Re^2: NO PERL 6
in thread NO PERL 6

Also, rule based syntax modification is lexically scoped, which is definitely handy...

How exactly is that supposed to work? It seems a bit paradoxical to me. Allowing lexical modification of the parser would have to happen at run-time; the only problem being that run-time is after compile-time :) I was under the impression that the process would be more like:

  1. The code must be in a BEGIN block or be use'd (same thing).
  2. The BEGIN block is parsed, compiled, and run with the current parser.
  3. When it is evident that parser rules are being overwritten, a copy of the parser is made.
  4. Modifications to the parser are actually made on the copy.
  5. When the BEGIN block exits, the modified parser becomes the real parser.

Replies are listed 'Best First'.
Re: Re: Re: Re^2: NO PERL 6
by Elian (Parson) on Dec 10, 2002 at 21:45 UTC
    Don't forget that uses are compile-time things. You throw the parser modification code into a module and use it in the block that you want it in effect for. The module then pushes the changes to the parser module out to the user's scope. Then, when the compiler continues on it uses the new parser code.

    Something like the way strict works now, pushing things out to its caller.

      So, will this code die 50% of the time?

      { $type = ('hex','oct')[rand 2]; eval qq[ rule Perl::Literals::$type::number { {die 'this base no longer exists'} } ]; print 0o017; }
        No, since the change won't make it out of the eval block, and the changes are done at runtime anyway. You need a use. The changes have to be in place at compile time to take effect.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://218919]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-02-21 09:10 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (276 votes). Check out past polls.