develooper Front page | perl.perl6.internals | Postings from August 2002

Re: [netlabs #801] [PATCH] PerlArray in scalar context

Thread Previous | Thread Next
From:
David M. Lloyd
Date:
August 14, 2002 10:32
Subject:
Re: [netlabs #801] [PATCH] PerlArray in scalar context
Message ID:
Pine.LNX.4.44.0208141228280.26801-100000@tomservo.workpc.tds.net
On Fri, 12 Jul 2002, Sean O'Rourke wrote:

> # New Ticket Created by  "Sean O'Rourke"
> # Please include the string:  [netlabs #801]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://bugs6.perl.org/rt2/Ticket/Display.html?id=801 >
>
>
> This patch makes the following behave as it does in Perl 5:
>
> @a = 1..3; @b = 1..3;
> $x = @a + @b;		# x is 6 in Perl 5, undef in Parrot
>
> The problem was that the math vtable methods were giving up if the other
> side of the operator wasn't an int or a num.  So the current version of
> PerlArray would make $x undef.  I'm not sure getting the other thing's
> int value (as opposed to its num value) is the right thing, but it seems
> like a reasonable guess.

Something tells me this approach isn't quite right but I don't know what.
It seems odd that, for instance, @a decides what context to take @b in.
How do we say 'scalar context' in Parrot?  What if @b is "Blah" in scalar
context?  Does it return 0 then?

Anyone with more powerful Jedi skills want to bless this patch?

- D

<dmlloyd@tds.net>


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