Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: __PACKAGE__ interpolated before inheritence

by wog (Curate)
on Dec 08, 2001 at 19:45 UTC ( [id://130421]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: __PACKAGE__ interpolated before inheritence
in thread __PACKAGE__ interpolated before inheritence

__PACKAGE__ is turned into, at compile time, the current package when it is compiled. (That is, the one established by package statements.)

Replies are listed 'Best First'.
Re4: __PACKAGE__ interpolated before inheritence
by blakem (Monsignor) on Dec 09, 2001 at 01:44 UTC
    To see this in action:
    % perl -MO=Deparse -e 'use constant Y => "foo"; $x="bar"; return __PAC +KAGE__, $x, Y' sub Y () { package constant; $scalar; } $x = 'bar'; return 'main', $x, 'foo'; # <=== inlined values at compile time...
    Notice that __PACKAGE__ and the constant Y got inlined at compile time, whereas $x did not.

    -Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://130421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-23 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found