Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Perl style: Arguing against three-argument join()

by martin (Pilgrim)
on Jan 24, 2008 at 19:03 UTC ( #664117=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl style: Arguing against three-argument join()
in thread Perl style: Arguing against three-argument join()

How does your second snippet "obfuscate the order of parts in the final result"?

The three strings to be concatenated are given in a different order than from left to right, which might be counter-intuitive for a casual reader.


Comment on Re^2: Perl style: Arguing against three-argument join()
Re^3: Perl style: Arguing against three-argument join()
by chromatic (Archbishop) on Jan 24, 2008 at 19:49 UTC

    That's silly. Someone who doesn't know what join does or the arguments it takes--or who doesn't know how to look it up in a reference or in the Perl documentation--has no business maintaining a serious Perl program. While there are definitely Perl operators with poor interfaces (caller is one of my least favorite), avoiding the use of join and slices because people who don't know Perl might not understand it is silly.

    (I realize you said "casual reader", which implies someone not reading carefully, but a similar argument applies there.)

Re^3: Perl style: Arguing against three-argument join()
by pilcrow (Sexton) on Jan 24, 2008 at 19:55 UTC
    The three strings to be concatenated are given in a different order than from left to right, which might be counter-intuitive for a casual reader.

    Fat arrow to the rescue?

    join $separator => @things{'this', 'that', 'the other'};

    However, where the task at hand is better described as prepending and appending to a string, rather than sewing together a list of arbitrary length, I concur with some others in this topic that concatenation is clearer.

    -Mike
Re^3: Perl style: Arguing against three-argument join()
by Erez (Curate) on Jan 25, 2008 at 19:57 UTC

    As a casual reader, albeit one that has used, and is used, to the join function, I had to go over the OP twice to understand what is said in the first option (join '',a,b,c). I can't really relate to using a function in a way that is counter intuitive to someone who is familiar with the way it should be used, but I'd hazard that for anyone who never used it, or Perl, neither will make sense; and if that person is to perldoc it, the first example might only serve to confuse more.

    Software speaks in tongues of man; I debug, therefore I code.
    Stop saying 'script'. Stop saying 'line-noise'.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-07-30 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (240 votes), past polls