Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^4: What operator should perl5porters use for safe dereferencing?

by Anonymous Monk
on Jun 05, 2012 at 09:52 UTC ( #974424=note: print w/replies, xml ) Need Help??

in reply to Re^3: What operator should perl5porters use for safe dereferencing?
in thread What operator should perl5porters use for safe dereferencing?

I'm curious, why add another operator? Why not use a prama to upgrade -> into being this new "safe" dereferencing operator?

And then get it included in strict in perl 5.18 or 5.20. Once this new functionality is introduced, why would anyone still want to use the original dereferencing operator?

Replies are listed 'Best First'.
Re^5: What operator should perl5porters use for safe dereferencing?
by BrowserUk (Pope) on Jun 05, 2012 at 11:52 UTC
    I'm curious, why add another operator?

    I've not been party to the discussion to implement this, so take my take on it in that light.

    Basically, some -- I would say most -- of the time, you do not want this behaviour.

    Most of the time, if you have a variable that should contain a reference, that your program logic requires you to call a method on (or dereference to use as a hash or array ref) then if it does not contain a reference, it is an error that your program cannot safely continue from, and all you can do is stop with an error message. Ie die.

    But there are sufficient cases where a potential reference not having a value is not fatal; that having to code an explicit test before each dereference clutters what could otherwise be clear and concise code.

    The use of different operators allows the programmer to cater for both situations cleanly, with little fuss.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974424]
[marto]: good morning all
[Discipulus]: good morning marto
[shmem]: good morning monkses and monksisses
[choroba]: Good morning!
[shmem]: GDPR meets butcher's shop
[marto]: if only Spectre had remained a fictional organisation :P https://www. php?page=news_item &px=Spectre-V3-V4- Vulnerabilities

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-05-22 07:15 GMT
Find Nodes?
    Voting Booth?