Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Apr 2010 06:21:14 -0700
From:      merlyn@stonehenge.com (Randal L. Schwartz)
To:        RW <rwmaillists@googlemail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: perl qstn...
Message-ID:  <86wrwkiunp.fsf@red.stonehenge.com>
In-Reply-To: <20100406132049.641b9edf@gumby.homeunix.com> (RW's message of "Tue, 6 Apr 2010 13:20:49 %2B0100")
References:  <4BB8108A.9080104@FreeBSD.org> <1270371713.5861.98.camel@tao.thought.org> <86aatjnsts.fsf@red.stonehenge.com> <861vevnsow.fsf@red.stonehenge.com> <j2ya14066a01004040945z39191770k2f025752317fb14a@mail.gmail.com> <20100404163353.GA15198@guilt.hydra> <20100404201442.b456044e.freebsd@edvax.de> <o2oa14066a01004041148zd4ef8167q32b04d58daec8f9f@mail.gmail.com> <4BB9A5ED.3040309@infracaninophile.co.uk> <20100405173632.739a0c42@gumby.homeunix.com> <20100406015544.GA21119@guilt.hydra> <20100406132049.641b9edf@gumby.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "RW" == RW  <rwmaillists@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@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86wrwkiunp.fsf>