In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/28c5c15c9196adf231d52b99e78f3de3d7b63e2b?hp=4a46fe99d0b8e1b85f7c17c5c73894e520adbf9e>

- Log -----------------------------------------------------------------
commit 28c5c15c9196adf231d52b99e78f3de3d7b63e2b
Author: Ian Goodacre <[email protected]>
Date:   Sat Oct 23 17:42:55 2010 +1300

    Clarify and correct description of comma operator in scalar context
    
    The guarantee that in scalar context the comma operator evaluates its
    arguments in scalar context is overstated.
    
    In perl 5.10.0
    
    print "Scalar assignment:\n";
    $x = ( context(1), context(2), context(3) );
    
    print "Scalar assignment in sub:\n";
    sub list { ( context(1), context(2), context(3) ) }
    $x = list();
    
    sub context {
    
        if(wantarray) {
            print "list context\n";
        } elsif(defined(wantarray)) {
            print "scalar context\n";
        } else {
            print "void context\n";
        }
    }
    
    prints:
    
    scalar assignment:
    void context
    void context
    scalar context
    Scalar assignment in sub:
    scalar context
    scalar context
    scalar context
    
    This leaves only the right argument of the last comma operator in a list as
    the only one that might always be evaluated in scalar context.
    
    The comments on the sample outputs were at best ambiguous if not misleading
    or false, and also unnecessarily pejorative of perl4. The revised comments
    less ambiguously refer to the last expression in the list (@y in the 
example)
    rather than to the literal list that is the argument of the assignment
    operator.

M       pod/perltrap.pod

commit 0f2dddf9d5446ead8d477e583a8d2c0191df31e1
Author: Ian Goodacre <[email protected]>
Date:   Sat Oct 23 16:46:02 2010 +1300

    Corrected Perl5 example of Formatted output and significant digits
    
    The following note says "Your results may vary...", so maybe some perls
    did give the value in the example as it was, but perl v5.10.0 on Intel
    Pentium based system gives the more accurate revised output.
    
    I am also dubious about the values given for perl4 as the error is quite
    large, but I don't have perl4 easily available to test.

M       pod/perltrap.pod

commit 5ad172142bcdae876148c9d21f887d2361cf2083
Author: Ian Goodacre <[email protected]>
Date:   Sat Oct 23 13:38:52 2010 +1300

    Added missing variable name in example code

M       pod/perltrap.pod
-----------------------------------------------------------------------

Summary of changes:
 pod/perltrap.pod |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index 3123436..99e25c8 100644
--- a/pod/perltrap.pod
+++ b/pod/perltrap.pod
@@ -665,7 +665,7 @@ are to used around the name.
     # perl4 prints: 2
     # perl5 fails with syntax error
 
-    @ = (1..3);
+    @a = (1..3);
     print "$#{a}";
 
     # perl4 prints: {a}
@@ -704,7 +704,7 @@ tries to be more precise.  For example, on a Solaris Sparc:
 
     # Perl5 prints:
     7.373504
-    7.375039999999999614
+    7.373503999999999614
 
 Notice how the first result looks better in Perl 5.
 
@@ -960,14 +960,15 @@ being required.
 =item * Comma operator in scalar context gives scalar context to args
 
 The comma operator in a scalar context is now guaranteed to give a
-scalar context to its arguments.
+scalar context to its last argument. It gives scalar or void context
+to any preceding arguments, depending on circumstances.
 
     @y= ('a','b','c');
     $x = (1, 2, @y);
     print "x = $x\n";
 
-    # Perl4 prints:  x = c   # Thinks list context interpolates list
-    # Perl5 prints:  x = 3   # Knows scalar uses length of list
+    # Perl4 prints:  x = c   # Interpolates array @y into the list
+    # Perl5 prints:  x = 3   # Evaluates array @y in scalar context
 
 =item * C<sprintf()> prototyped as C<($;@)>
 

--
Perl5 Master Repository

Reply via email to