develooper Front page | perl.perl6.language | Postings from May 2005

Re: not 4,3,2,1,0;

Thread Previous | Thread Next
Autrijus Tang
May 16, 2005 14:32
Re: not 4,3,2,1,0;
Message ID:
On Mon, May 16, 2005 at 12:49:13PM -0700, Larry Wall wrote:
> On Tue, May 17, 2005 at 01:48:20AM +0800, Autrijus Tang wrote:
> : This evaluates to 1 in Perl 5: 
> : 
> :     not 4,3,2,1,0;
> : 
> : Namely, the "not" listOp is taking the last of a variadic, non-slurpy
> : argument list, boolify it, and return its negation.
> : 
> : What is the Perl 6 signature that correspond to this behaviour?
> There is none.  Wherever Perl 5 defaults to "last of list", Perl
> 6 doesn't.  If you wanted to emulate it in user code, you'd have "is
> context(Scalar)" or some such and then explicitly ignore all but the
> last value in your implementation.  But no built-ins rely on C-comma
> behavior.

Ok, but I'm still not too sure about what signature will Perl 6's &not
have, that can impose singular context on each of its argument (so that
not(@foo) won't flatten), but still accept an unlimited number of
arguments.  It's something like:

    multi sub not (Bool $x1)
    multi sub not (Bool $x1, Bool $x2)
    multi sub not (Bool $x1, Bool $x2, Bool $x3)

But I'm not sure about how to express it in one line.

> No.  In list context it should do !俎4,3,2,1,0].  In scalar context it
> should probably return something like !any(4,3,2,1,0) or none(4,3,2,1,0)
> or whatever we decide makes our collective brain hurt the least.

IMHO, having not($x, $y, $z) simply mean !(any($x, $y, $z)) is
easiest to explain.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About