develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [PATCH] Add open "|-" and open "-|" to perlopentut

Thread Next
Tom Christiansen
August 25, 2008 09:54
Re: [PATCH] Add open "|-" and open "-|" to perlopentut
Message ID:
In-Reply-To: Message from "H.Merijn Brand" <> 
	     of "Mon, 25 Aug 2008 11:36:22 +0200." 

> On Mon, 25 Aug 2008 02:35:24 -0600, [I,] Tom Christiansen
> <>, wrote:

>>> I converted the '|-' example to "lpr".  
>> Nice to see better quotes.

>>>> Finally, should these examples be included *before* the
>>>> references to IPC::Open2 and perlipc?  
>>> Don't know.  
>> No.

>>> New patch attached.  

>> How delightful: politically-correct Bow[d]lerization in programming
>> languages' documentation.  Must we fiddle about with t's that are
>> already crossed whilst Rome is burning?

>> For the record, and if I were to fix it back up so it actually reads as
>> I write (and would see other[s] write) again, I'd certainly make doubly
>> [sure] always to use double-quotes in all places other than those scant
>> few that have just cause to see interpolation suppressed.

> I have had my disputes with you, but I wholeheartedly agree with you
> for 100% on the use of double quotes here!

I'm glad that, despite producing so long a missive--nay, arguably more 
of a document than a simple letter--more riddled with typos than a 
moth-eaten old sweater is with holes, I still managed to convey my 
point in a convincingly persuasive manner.  But such are the perils 
of writing in those wee small hours of the unborn day.

The argument for using double quotes over singles distills down to two
major points, the first simple and the second subtler:

    1) They're easier to read because they're wider, dodging also the 
       late-night `grave-vs-acute' quandary of dim vision or bad fonts.

    2) Perl is fundamentally *interpolative* by nature, and so its default
       behaviour--one seen in many, many places--is to interpolate; forever
       fighting against that nature is more trouble than it's worth.

Interpolated strings literals are no different in this regard than many
another construct in Perl.  Indeed, in places other than strings, Perl's
inherently interpolative nature may be suppressed only via incantations
substantially more convoluted (read: uglier) than resorting to single quotes.

Reserve therefore the special, *suppressive* syntax for that rare occasion
when you genuinely require it.  Do not use it out of mindless habit and so
needlessly force the reader to try to discern whether you *meant* to
suppress something, what that was, and why.

Plus, that path also avoids confusing both shell and C programmer alike, 
who expect and intend \t or \n to mean but single characters, not doubles.

Lastly, if you start out with single quotes, you'll too often have to
change the whole thing when you later find yourself needing to include
some backslashed character or a variable.  By using double quotes from 
the onset, you save yourself work in the future, and perhaps also run 
less risk of error.


PS: I know: those final two paragraphs could count as points 3 and 4. 
    But these are a minor pair of points compared with the major pair.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About