SQL call formatting style

Gervase Markham gerv at mozilla.org
Sat Mar 29 10:42:01 UTC 2003


Bradley Baetz wrote:
> well, generally we'd prefer '' (or q{}) because they don't inerpolate.

Is this for performance reasons? Interpolation isn't bad unless you want 
to literally use some special characters. How common is that? The 
advantage of using " " is that you can embed ' without escaping.

> The main difference is that we can include quotes in there, without
> extra escaping which is harder to read. Not for params (which use ?
> placeholders), but more for literal strings. Compare:

So, basically it's a trade-off between using:

" ", which allow you to embed the common ' without escaping, but if you 
want literal values of e.g. $, you have to escape those

and

' ', which require escaping of embedded single quotes in a few rare cases

and

q{ }, which I find harder to read (and, perhaps, people with less Perl 
familiarity might not recognise), but don't require such escaping.

As I've said, I find quotes around strings mentally much less jarring, 
because it's what I expect. q{ } always makes me think of a function 
call (which it is, really.)

We should choose what's most readable for most people in the common 
case. Obviously, others will chime in, but in my view, that is either '' 
or " " as appropriate, with a spot of escaping in a small number of 
places as necessary.

> It also looks a bit nicer in editors - you can distinguish it from
> 'regular' strings, for example based on syntax highlighting.

I'd rather it was highlighted as a regular string actually, because 
that's what it is :-)

Gerv




More information about the developers mailing list