Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: How do I pretend a reference isn't a reference

by clinton (Priest)
on Nov 06, 2008 at 12:54 UTC ( #721975=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How do I pretend a reference isn't a reference
in thread How do I pretend a reference isn't a reference

It depends what sub _ is defined to be, at compile time :) Check my code in Re^2: How do I pretend a reference isn't a reference and you'll see that $foo WOULD contain an object there.


Comment on Re^4: How do I pretend a reference isn't a reference
Select or Download Code
Re^5: How do I pretend a reference isn't a reference
by Anonymous Monk on Nov 06, 2008 at 14:00 UTC
    No it doesnt.
    sub _ { 'compile time '.@_}; local *_ = sub { 'run time '.@_}; # the above is what your module/init code does my $c = _(1); die $c; __END__ run time 1 at - line 6.
    You were saying that $c is one thing at runtime, another at compile time. Its only something at runtime.
Re^5: How do I pretend a reference isn't a reference
by clinton (Priest) on Nov 06, 2008 at 14:37 UTC

    That's not what my code does, nor was I saying that $c was one thing at compile time and one at run time. This is what I do:

    # init the app sub _ { 'compile time '.@_}; my $compile = _(1); sub foo { _(1) }; # finished compiling, so redefine sub _ sub _ { 'run time '.@_}; # run the code my $run = foo(); print " $compile - $run\n" __END__ compile time 1 - run time 1
    UPDATE: Meant to reply to Re^5: How do I pretend a reference isn't a reference

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-10-20 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (77 votes), past polls