not 4,3,2,1,0;

1 view
Skip to first unread message

Autrijus Tang

unread,
May 16, 2005, 1:48:20 PM5/16/05
to perl6-l...@perl.org
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?

Also, is this still sane for Perl 6's &not?

Thanks,
/Autrijus/

Larry Wall

unread,
May 16, 2005, 3:49:13 PM5/16/05
to perl6-l...@perl.org
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.

: Also, is this still sane for Perl 6's &not?

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.

Larry

Autrijus Tang

unread,
May 16, 2005, 5:32:27 PM5/16/05
to perl6-l...@perl.org
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.

Thanks,
/Autrijus/

Larry Wall

unread,
May 16, 2005, 7:06:15 PM5/16/05
to perl6-l...@perl.org
On Tue, May 17, 2005 at 05:32:27AM +0800, Autrijus Tang wrote:
: 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.

That's

sub not (*args is context(Scalar))

or whatever we end up calling the Any/Scalar type.

Larry

Autrijus Tang

unread,
May 17, 2005, 2:42:43 AM5/17/05
to perl6-l...@perl.org
On Mon, May 16, 2005 at 04:06:15PM -0700, Larry Wall wrote:
> That's
>
> sub not (*args is context(Scalar))
>
> or whatever we end up calling the Any/Scalar type.

How about is context(Item) versus is context(Slurpy). :)

Also, shouldn't the *args there be *@args? Is it really okay
to use a sigilless parameter name by default?

Thanks,
/Autrijus/

Larry Wall

unread,
May 17, 2005, 4:24:53 AM5/17/05
to perl6-l...@perl.org
On Tue, May 17, 2005 at 02:42:43PM +0800, Autrijus Tang wrote:

: On Mon, May 16, 2005 at 04:06:15PM -0700, Larry Wall wrote:
: > That's
: >
: > sub not (*args is context(Scalar))
: >
: > or whatever we end up calling the Any/Scalar type.
:
: How about is context(Item) versus is context(Slurpy). :)

I've been kind of leaning towards Item lately for the Any type, but
the other one could just be whatever we end up calling lazy lists,
which is probably not Slurpy.

: Also, shouldn't the *args there be *@args? Is it really okay


: to use a sigilless parameter name by default?

Yes, that was just a typo.

Larry

Juerd

unread,
May 17, 2005, 4:36:06 AM5/17/05
to perl6-l...@perl.org
Larry Wall skribis 2005-05-17 1:24 (-0700):

> : How about is context(Item) versus is context(Slurpy). :)
> I've been kind of leaning towards Item lately for the Any type, but
> the other one could just be whatever we end up calling lazy lists,
> which is probably not Slurpy.

Well, slurping and steam rolling are different things. Even slurp() can
return a lazy list, and lazy lists don't mind going into a subroutine's
slurpy array. List flattening doesn't (shouldn't) require immediate
evaluation.

I see no reason to not call it Slurpy. If there is any reason to not
call it that, we also need new names for slurp() and slurpy parameters.


Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html

Reply all
Reply to author
Forward
0 new messages