perl qstn...

Randal L. Schwartz merlyn at stonehenge.com
Tue Apr 6 13:21:15 UTC 2010


>>>>> "RW" == RW  <rwmaillists at googlemail.com> writes:

RW> Imperative languages have a natural order of decision followed by
RW> action, and code is most easily readable if the syntax doesn't try to
RW> subvert that.  

And yet, there's an equally valid argument that the most important
thing should stand out the most.  In that sense, in the Perl statement:

  warn "x = $x, y = $y, z = $z\n"
    if $debug;

... the most important part is that it's printing something to stderr,
and what's being printed.  It's only minor that it's only when
debugging, and luckily Perl lets us relegate that to the tail end of
the statement.

Now, if you argue "oh, the most important thing there is 'if debug'",
then fine, you'd write that as:

  if ($debug) { warn ... }

And I'd be fine with that.  But I tend to see that layout as a lot of
noise just to add a minor conditional.  Or you could speak Perl
with a Shell accent, and say

  $debug and warn ...;

Fine, that also works, and some part of your audience will hate you,
and another part will be totally cool with it.

But this *is* the reason There's More Than One Way To Do It in Perl.
You can write Perl that most naturally expresses what you believe
is important in the code.

If you don't like all this freedom, there's always Python. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


More information about the freebsd-questions mailing list