develooper Front page | perl.perl5.porters | Postings from March 2000

[PATCH] perlsyn.pod

Thread Next
From:
Tom Christiansen
Date:
March 22, 2000 10:44
Subject:
[PATCH] perlsyn.pod
Message ID:
24629.953750643@chthon
Two fixes.  

1) Precedence bug in goto example..

2) Fixes for the repugnant "foreach my". 

One *cannot* in English produce a phrase such as "for each my".  
It's illegal.

The fact is that this

    for my $part (@roles) 

reads infinitely better than does

    foreach my $part (@roles) 

Because like demonstratives ("this", "those", &c) and articles ("a",
"the", &c), both "each" and "my" pertain to that grammatical class
known as _determiners_, and English, you see, simply does not admit
more than one determiner on a given noun!  Try saying "for the my
big house" or "for his that friend".  I have the same problem with
"for each my part".  My internal grammar can't produce a double
determiner, so neither does my Perl.  Of course, regular adjectives
like "local" or "integral" have no such restriction, so in fact
"for each local adminstrator" is fine.

Sso is "for our $part".  But not "foreach our $part"!  perl5004delta.pod,
perlop.pod, and perlthrtut.pod also constriubte to this complete
silliness.

--tom


--- /usr/local/src/perl-5.6.0-RC3/pod/perlsyn.pod	Mon Mar 13 14:25:37 2000
+++ /tmp/perlsyn.pod	Wed Mar 22 11:38:14 2000
@@ -324,7 +324,7 @@
 
     for (@ary) { s/foo/bar/ }
 
-    foreach my $elem (@elements) {
+    for my $elem (@elements) {
 	$elem *= 2;
     }
 
@@ -353,8 +353,8 @@
 Whereas here's how a Perl programmer more comfortable with the idiom might
 do it:
 
-    OUTER: foreach my $wid (@ary1) {
-    INNER:   foreach my $jet (@ary2) {
+    OUTER: for my $wid (@ary1) {
+    INNER:   for my $jet (@ary2) {
 		next OUTER if $wid > $jet;
 		$wid += $jet;
 	     }
@@ -525,7 +525,7 @@
 dynamically.  This allows for computed C<goto>s per FORTRAN, but isn't
 necessarily recommended if you're optimizing for maintainability:
 
-    goto ("FOO", "BAR", "GLARCH")[$i];
+    goto(("FOO", "BAR", "GLARCH")[$i]);
 
 The C<goto>-&NAME form is highly magical, and substitutes a call to the
 named subroutine for the currently running subroutine.  This is used by

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About