Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Real private methods using lexical subs in Perl 5.18.

by LanX (Saint)
on Jun 01, 2013 at 08:51 UTC ( [id://1036399]=note: print w/replies, xml ) Need Help??


in reply to Re: Real private methods using lexical subs in Perl 5.18.
in thread Real private methods using lexical subs in Perl 5.18.

> This is very interesting. I wonder why the ugly mega-sigil is required

The mega-sigil is actually a workaround to call the lexical sub as a code-ref like described in the update.

Keep in mind that for Perl the names in method calls are syntactically literal strings messaged to the object. And literal strings can't be scoped.

I.a.W. Perl can't tell if you call $obj->private within the package/class or not. But generally allowing it fundamentally violates the definition of privacy.

Calling $obj->$code_ref doesn't have this limitation, cause scalars can be lexically scoped.

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found