develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132537] possible documentation error in perldata

Thread Previous | Thread Next
From:
Christoph Anton Mitterer
Date:
December 14, 2017 14:38
Subject:
Re: [perl #132537] possible documentation error in perldata
Message ID:
1512879084.25544.7.camel@scientia.net
On Fri, 2017-12-08 at 01:12 -0800, Dave Mitchell via RT wrote:
> It does by definition:
> No, in scalar context, there isn't a list; instead there is merely
> a sequence of comma operators (which return their RH argument), with
> parentheses added for the purpose of precedence.

That's at least not how the text in perldata or perlop does it make
look like.
It's rather written as it's still a list (and it even says, that all
elements are actually evaluated), just that it doesn't "return" the
whole list, but rather only it's last element.


- (x, y, z) seems to be clearly what is defined to be a list, every
  beginner will consider it as such, regardless of its context
- other text places say that in both contexts (scalar/list) all
  elements are evaluated, just that in scalar context everything but
  the last is discarded

So conceptually it still seems to be a list, and then the text that I
was mentioning is still ambiguous...
People would think (by operator precedence):
1. evaluation of the x, y, z (i.e. the list)
   and the text says always in list context
2. for list context   = return all evaluated elements as a list
   for scalar context = return only the last element (which would
   however, by the documentation, be evaluated in list context, which
   it is not.


Cheers,
Chris.

Thread Previous | 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