From: Andreas Ericsson <ae@op5.se>
To: Junio C Hamano <junkio@cox.net>
Cc: "Randal L. Schwartz" <merlyn@stonehenge.com>,
Alex Riesen <raa.lkml@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] git-mv.perl: use stderr for error output and cleanup
Date: Sun, 08 Jan 2006 01:07:25 +0100 [thread overview]
Message-ID: <43C057BD.7010201@op5.se> (raw)
In-Reply-To: <7v7j9bg369.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
>
> BTW, I never understood the usefulness of Statement Modifiers.
> Even reading the examples in perlsyn.pod:
>
> print "Basset hounds got long ears" if length $ear >= 10;
> go_outside() and play() unless $is_raining;
>
> seeing "do these things" upfront and then realize "ah, but that
> is done only when this holds true", interrupts the flow of
> understanding while reading a program by somebody else [*1*].
Here's what "Programming Perl" by O'Reilly (third edition, somewhere
around page 604) has to say about it:
---%<---%<---%<---
*) Do things the most readable way. For instance:
open(FOO, $foo) or die "Can't open $foo: $!";
is better than
die "Can't open $foo: $!" unless open(FOO, $foo);
because the second way hides the main point of the statement in a modifier.
---%<---%<---%<---
Considering the book was co-authored by Larry Wall, I'd say that's as
good as an apology.
> It is worse if the Statement Modifier is a loop control.
>
> (flamebait) Compound Statements take BLOCK and people who want
> to do a one-liner could not do so without braces. I've always
> thought Statement Modifies as a lame workaround for that
> problem.
>
Most things can be done without braces, so long as one doesn't spell out
the 'if'.
$opt_h and usage();
-d $directory or mkdir($directory);
is perfectly valid perl. This way of writing it is familiar enough for
shell-scripters. Hardcore C-programmers will look twice when they see a
line that so obviously looks completely wrong and will almost certainly,
with some revulsion, understand it.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
next prev parent reply other threads:[~2006-01-08 0:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-05 11:49 [PATCH] git-mv.perl: use stderr for error output and cleanup Alex Riesen
2006-01-06 22:38 ` Junio C Hamano
2006-01-06 22:55 ` Randal L. Schwartz
2006-01-06 23:28 ` Linus Torvalds
2006-01-06 23:53 ` Randal L. Schwartz
2006-01-07 0:10 ` Linus Torvalds
2006-01-07 0:46 ` Junio C Hamano
2006-01-07 10:28 ` Alex Riesen
2006-01-07 10:29 ` Junio C Hamano
2006-01-10 22:24 ` Alex Riesen
2006-01-07 10:34 ` Randal L. Schwartz
2006-01-07 21:04 ` Junio C Hamano
2006-01-08 0:07 ` Andreas Ericsson [this message]
2006-01-10 22:26 ` Alex Riesen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43C057BD.7010201@op5.se \
--to=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=merlyn@stonehenge.com \
--cc=raa.lkml@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).