Re: [PATCH] git-mv.perl: use stderr for error output and cleanup

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] git-mv.perl: use stderr for error output and cleanup

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:16

merlyn@stonehenge.com (Randal L. Schwartz) writes:
quoted
quoted
Being as I'm a *bit* familiar with Perl, I'd write that as:

print H "$_\0" for @deletedfiles;
...  It was added for Perl 5.5, first released on 22 July 1998.
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*].
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.

[Footnote]

*1* This is true even for me; my mother language is Japanese,
which tends to hang negation at the tail of the sentence, and
double negation is not unusual.  This makes it impossible to
know what a sentence states before reading it to the end, so I
am used to that "coming back to the main part after reading
through the sentence", but I do not welcome that when I am
reading programs.

Re: [PATCH] git-mv.perl: use stderr for error output and cleanup

From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:42:16

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help