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

Re: What operator should perl5porters use for safe dereferencing? (Specification?)

by LanX (Canon)
on Jun 02, 2012 at 13:50 UTC ( #974016=note: print w/ replies, xml ) Need Help??


in reply to What operator should perl5porters use for safe dereferencing?

I'm confused!

The poll is bout calling methods on undef instead of a blesses ref, the linked p5p discussions I read so far are about avoiding autovivication when dereferencing nested var-refs.

So which cases are covered?

Cheers Rolf


Comment on Re: What operator should perl5porters use for safe dereferencing? (Specification?)
Re^2: What operator should perl5porters use for safe dereferencing? (Specification?)
by ambrus (Abbot) on Jun 03, 2012 at 09:06 UTC

    Both of those!

    $r&->f would behave something like $r && $r->f so it would call method f on the object $r if it's set, or do nothing and return undef if $r is undefined.

    $h{$w}&->() would look the word $w up in the hooks table %h, and if there's an entry, call it as a subref, but if there's no entry, it would just nop silently.

    Finally, $t{$x}&->{$y} would be like $t{$x}{$y} only it doesn't autovivify $t{$x} as a hashref if it doesn't exist.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-08-21 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls