Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by phaylon (Curate)
on Jun 25, 2012 at 17:40 UTC ( [id://978229]=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 disagree with regard to "logical." This is clearly a discussion about preferences. And for me "~>" is way too close to "->", and if the font makes it not look too similar, it also makes it not look like an arrow anymore.

Your theory about skimming it seems to be dependent on the previous developer doing everything right. What if ~> was used by accident? What if it's in the wrong place of the expression?

Thus, my personal preference is for "?->". I find it clearer, since it stands out more. This also has the advantage that somebody who doesn't know it doesn't just scan it as "->" and wonder why everything goes wonky. They see something that doesn't make sense to them immediately and have to look it up.


Ordinary morality is for ordinary people. -- Aleister Crowley
  • Comment on Re^4: What operator should perl5porters use for safe dereferencing?

Replies are listed 'Best First'.
Re^5: What operator should perl5porters use for safe dereferencing?
by BrowserUk (Patriarch) on Jun 25, 2012 at 19:07 UTC
    Your theory about skimming it seems to be dependent on the previous developer doing everything right. What if ~> was used by accident? What if it's in the wrong place of the expression?

    I do not believe so.

    In every accidental mis-usage scenario I can imagine, if the reference is undef, the result of the dereference expression will be undef, and so will trigger an undefined value warning the first time it is used.

    Of course, the first usage my be remote from its generation, but tracing undefs back to their source is a common enough procedure in Perl now, and is hardly rocket science. I do not see the shape of the operator being a major factor either way.

    I think the only way I can counter your premise, is to respond to example usage in-situ. And producing examples realistic enough to form the basis of serious discussion is very difficult.

    You inevitably end up arguing about the validity of the example, rather than the merits of the case being presented.

    In the end, I can only express my opinion along with everyone else's and counter what I see as bad arguments, in the hope of influencing those making the decision. Assuming it hasn't already been made.


    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?

      Oh, I didn't mean to counter all of your arguments with that point. It was more geared towards the visibility during scanning larger bodies of code. Especially that the general need to deal with the different behaviour would give a visual clue. This is what I would regard depending on that visual clue being there.

      With regard to undef hunting, I assume our typical day-to-day problems are just different. This is where I would really welcome a separate clue like a more distinguished operator. After all, undefined can also mean false, so a (remote) expression involving "~>" could very well result in valid, but unwanted behavior. At this point one might not even know that one is hunting undefined values.

      An additional scenario would be code reviews: I'd have to look much more closely to make sure nobody sneaks in a "~>" where it shouldn't be. This would even be for reviewing my own code. If I refactor a piece of code I have to pay more attention to the arrows.

      Just want to note that I don't regard your opinions as wrong, they just differ from mine. I hope I'm doing a half-way decent job at explaining why I hold these views :) Do you have anything against "?->" visually itself, or do you simply prefer "~>" for being more concise (or something else)?


      Ordinary morality is for ordinary people. -- Aleister Crowley
        I'd have to look much more closely to make sure nobody sneaks in a "~>" where it shouldn't be.

        Sorry, but that is a bit of a crock.

        ~> versus ->, is certainly no harder to "detect" than . versus ',', (or $l .v. $1, O .v. 0 etc.) and the results can be equally mysterious and damaging.

        If your font is unclear, use a proper programming font.

        If your eyesight is poor -- as mine is -- use a bigger font.

        Just want to note that I don't regard your opinions as wrong, they just differ from mine. I hope I'm doing a half-way decent job at explaining why I hold these views :)

        Ditto! (And you have:)

        Do you have anything against "?->" visually itself, or do you simply prefer "~>" for being more concise (or something else)?

        My eyes/brain have become used over the past 30 years or so to translating -> into points at, without conscious effort.

        In the smae way as you can raed tihs snetnce wihtupt dicffiluty dsetite the tpyos, I believe that I will be able to read $ref~>meth( $arg ) equally easily.

        However, I think that every time I encountered $ref?->meth( $arg ), that ? is going to stand out like a sore thumb, ring an alarm bell, and throw a brake on my flow.

        And given that the vast majority of the time, $ref~>meth( $arg ) will act exactly like $ref->meth( $arg ), that would be giving it a prominence that it simply does deserve or warrant. (IMO:)

        Stated the other way, I think that when you need to notice it, ~> is sufficiently different; but when you don't need to notice, it is sufficiently similar to ->, as to not cry wolf in your subconsciousness.


        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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found