Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

On Compilation, Call Trigger Policy: Now vs Inline

by ian (Beadle)
on Dec 06, 2007 at 10:04 UTC ( #655339=perlquestion: print w/replies, xml ) Need Help??
ian has asked for the wisdom of the Perl Monks concerning the following question:

While reading The Camel, ch18 Table 18-1 on page 484 (3rd edition), I came across this notion of "Call trigger Policy".

I'm confused about the difference between "Inline", and "Now".

I see that "Now" applies to BEGIN blocks, and this seems straightforward. But then eval introduces "Inline", and "Call later". I believe I saw someone earlier tonight give some example with print and sub's evaluating their arguments; I believe this means "jumping back" from runtime into compile time.

-- Ian Tegebo

Replies are listed 'Best First'.
Re: On Compilation, Call Trigger Policy: Now vs Inline
by sh1tn (Priest) on Dec 06, 2007 at 13:45 UTC
    It is written:If you think of an eval STRING as a call back from the interpreter to the compiler, then you might think of a BEGIN as a call forward from the compiler into the interpreter. Both temporarily put the current activity on hold and switch modes of operation.

    Pretty self-explanatory.
    print "start main running here\n"; eval "BEGIN{print qq(BEGIN: before eval compilation at run-time +\n)} END{print qq(END: from eval STRING\n)}"; eval {BEGIN{print qq(BEGIN: before eval compilation at compile-t +ime\n)} END{print qq(END: from eval BLOCK\n)}}; END { print "END: done running\n" } BEGIN { print "BEGIN: still compiling\n" }

      I'm in agreement about the straightforwardness of call back and call forward with respect to interpreter->compiler and compiler->interpreter; it's the difference between the call trigger policy of "Now" vs "Inline" that's confusing to me. Is it merely that BEGIN is always triggered at the beginning of the line versus an eval which can be triggered anywhere within one?
      -- Ian Tegebo
Re: On Compilation, Call Trigger Policy: Now vs Inline
by Anonymous Monk on Dec 06, 2007 at 11:08 UTC
    Most monks don't have that book

      Most monks don't have that book

      Most monks don't have Programming Perl? I'd say other wise, most monks *do* have it. I don't read passages from it every night before I go to sleep, but I have a copy at my work desk. It's the second best thing to a canonical text in the Perl community.

      Software speaks in tongues of man; I debug, therefore I code.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://655339]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2018-04-26 04:16 GMT
Find Nodes?
    Voting Booth?