Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by Anonymous Monk
on May 29, 2012 at 14:29 UTC ( #973036=note: print w/ replies, xml ) Need Help??


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

Interesting
 -> $rock->()->the->kasbah(); $rock->  ()->  the->   kasbah();
 ~> $rock~>()~>the~>kasbah(); $rock~>  ()~>  the~>   kasbah();
 &> $rock&>()&>the&>kasbah(); $rock&>  ()&>  the&>   kasbah();
 ?> $rock?>()?>the?>kasbah(); $rock?>  ()?>  the?>   kasbah();
 +> $rock+>()+>the+>kasbah(); $rock+>  ()+>  the+>   kasbah();
 !> $rock!>()!>the!>kasbah(); $rock!>  ()!>  the!>   kasbah();
 ->> $rock->>()->>the->>kasbah(); $rock->> ()->> the->>  kasbah();
 ->-> $rock->->()->->the->->kasbah(); $rock->->()->->the->-> kasbah();
 ==> $rock==>()==>the==>kasbah(); $rock==> ()==> the==>  kasbah();
 ?-> $rock?->()?->the?->kasbah(); $rock?-> ()?-> the?->  kasbah();
 ->? $rock->?()->?the->?kasbah(); $rock->? ()->? the->?  kasbah();
 &-> $rock&->()&->the&->kasbah(); $rock&-> ()&-> the&->  kasbah();
 &&-> $rock&&->()&&->the&&->kasbah(); $rock&&->()&&->the&&-> kasbah();
 -&> $rock-&>()-&>the-&>kasbah(); $rock-&> ()-&> the-&>  kasbah();
 -&&> $rock-&&>()-&&>the-&&>kasbah(); $rock-&&>()-&&>the-&&> kasbah();
 ->& $rock->&()->&the->&kasbah(); $rock->& ()->& the->&  kasbah();
 ->&& $rock->&&()->&&the->&&kasbah(); $rock->&&()->&&the->&& kasbah();
 -=> $rock-=>()-=>the-=>kasbah(); $rock-=> ()-=> the-=>  kasbah();
 =-> $rock=->()=->the=->kasbah(); $rock=-> ()=-> the=->  kasbah();
 ?> $rock?>()?>the?>kasbah(); $rock?>  ()?>  the?>   kasbah();
 ?-> $rock?->()?->the?->kasbah(); $rock?-> ()?-> the?->  kasbah();
 ?->: $rock?->:()?->:the?->:kasbah(); $rock?->:()?->:the?->: kasbah();
 ~>: $rock~>:()~>:the~>:kasbah(); $rock~>: ()~>: the~>:  kasbah();


Comment on Re^2: What operator should perl5porters use for safe dereferencing?
Select or Download Code
Re^3: What operator should perl5porters use for safe dereferencing?
by BrowserUk (Pope) on May 29, 2012 at 16:07 UTC

    That seals it for me. ~> it is.

    Everything else just looks like an ant with the squits ran across the page even when you add a few spaces.


    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?

      Heh. I had a similar reaction for ->> but I confess that ~> is a strong second.

      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?

        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?

Re^3: What operator should perl5porters use for safe dereferencing?
by Argel (Prior) on May 29, 2012 at 22:01 UTC
    Wow, amazing what a difference actual examples make!! Visually, ~> is the clear winner. Thanks for making the chart!!

    Elda Taluta; Sarks Sark; Ark Arks
    My deviantART gallery

Re^3: What operator should perl5porters use for safe dereferencing?
by ikegami (Pope) on May 30, 2012 at 16:06 UTC
    That eliminates ~> as far as I'm concerned. Way too similar to ->.

      The main problem I have with ~> is the change in shift key. The ~ is on the left side of the keyboard (at least my US-style keyboard), so touch typists will use the right shift key. > is on the right, thus the use of the left shift key. tchrist's "Twister" moniker comes in to play here - try typing it out a few times to see how easy/difficult it is. Maybe for hunt-and-peck typists there won't be much difference. For touch typists, we could come up with an alternative that was less discordant (such as ->>).

      The fact that a quick glance at code wouldn't always tell the difference between -> and ~> is, in my opinion, both a positive and a negative. Positive in that they are so tightly related and often that's good enough, but negative in having to mentally switch gears to actually pay attention and notice it when it matters.

        Hmm, maybe Iím using my keyboard wrong, but Iím one of those people who more often than not use the right shift (the left being tiny due to the European style 102-key key layout). Even if I had a preference for the left shift key though, the thing would be the same: press shift, press one of the keys, press the other key with the other hand, release shift. If anything, -> is ever so slightly harder to type because the precise timing needed between the two keystrokes, whereas ~>ís both characters are on the same shift level on English layouts at least.

        My problem with ~> is that on certain font sizes with certain fonts and certain hinting settings, FreeType makes the tilde look like a straight bar.

        An excellent point. I hope it gets taken into consideration.


        - Boldra
        The ~ is on the left side of the keyboard (at least my US-style keyboard), so touch typists will use the right shift key...

        There are people who use the right shift key? Seriously?

        Huh. I use the right shift key about as often as the right alt and right ctrl keys -- which is to say, somebody could sabotage those keys as an April Fools joke so that pressing them does nothing, and it could be five years or more before I notice, depending on when I finally get around to cleaning out my keyboard thoroughly (as opposed to just quickly running an ISO long narrow object between the keys to get most of the hair out, which is what I usually do).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-23 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (135 votes), past polls