SQL call formatting style
Christopher Hicks
chicks at chicks.net
Sat Mar 29 17:02:58 UTC 2003
On Sat, 29 Mar 2003, Gervase Markham wrote:
> 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.)
Around simple single-line strings I tend to agree, but when you're dealing
with multi-line SQL statements or other significant hunks of inline text,
the q{} form isn't as grating.
> We should choose what's most readable for most people in the common
> case.
Readability is deceptive in this case. I doubt anyone wants '' because
you have to escape the 's often needs. That leaves q{} or "". "" would
be more readable according to your preference, but it causes side effects
that people don't expect. Numerous scripts I've read do things like:
$addy = "chicks at chicks.net";
Obviously these folks were ignoring warnings and otherwise naive, but it
exhibits that people new to perl don't consider the interpolation effects.
In teaching Perl I've seen a lot of students, particularly those from the
C and COBOL worlds trip over this. So, you're left teaching people the
plethora of interpolation intricacies or "hay, these q{} things are safe
quotes". Particularly if the q{} is used through the main code base,
people will end up cutting and pasting it, and get used to the paradigm. I
suspect that doing so would help avoid bugs. Avoiding escaping seems like
a readability win too.
--
</chris>
The death of democracy is not likely to be an assassination from ambush. It
will be a slow extinction from apathy, indifference, and undernourishment.
-Robert Maynard Hutchins, educator (1899-1977)
More information about the developers
mailing list