develooper Front page | perl.perl5.porters | Postings from November 2015

Re: [perl #126749] FR: get more benefit from ||, &&

Thread Previous
From:
Ricardo Signes
Date:
November 27, 2015 19:12
Subject:
Re: [perl #126749] FR: get more benefit from ||, &&
Message ID:
20151127191201.GA10711@cancer.codesimply.com
* KES <kes-kes@yandex.ua> [2015-11-27T13:37:07]
> The doc says that Perl really do this: @x = scalar(@y) || @z;
> *But it is ugly to get scalar result when we want the list* ( the behaviour of || in this case is ugly a bit )
> There is no any reason to not return list ( @y ) in this case (except for backward compatibility. but in any case
> we may not allow this feature by default in future versions of perl)

There is already utility in the current behavior, if you expect it.  What you
describe could also have been a useful behavior, and maybe if we had godlike
awareness we could know whether it would be more useful and less surprising.

As it is, though, the backward compatibility is a huge issue, and breaking it,
even if guarded by a pragma, does not seem warranted.  Code would become much
harder to skim code because one would need much more context for understanding
very basic things like "what context does this operator produce in this
context," and across call boundaries.

This is not going to get changed.

-- 
rjbs

Thread Previous


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