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

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

Thread Previous
From:
Sean O'Rourke
Date:
August 25, 2002 09:57
Subject:
Re: [netlabs #801] [PATCH] PerlArray in scalar context
Message ID:
Pine.GSO.4.32.0208250945290.13442-100000@gradlab.ucsd.edu
I ran across this in looking at tidying up old bugs.  It seems like things
are backwards below -- hyper-operation is a language-level shorthand for
iteration over a container, so there's no reason for the container's
vtable methods to be "hyper".  Actually, it seems like there are at least
a couple ways in which pushing this responsibility onto vtable methods may
not be the best way: if we "hype" non-vtable methods, we have to handle
explicit iteration in bytecode; and if we hyper-operate on tied variables,
they have to re-implement this looping behavior in their add, etc methods.

It looks like the standard perl5 behavior is implemented by the current
vtable methods (hyping done separately), but I wanted to make sure we were
on the same page before closing the bug.

/s

On Wed, 14 Aug 2002, David M. Lloyd wrote:
> [what PerlArray vtable methods should do for "$x = @a + @b"]
> I thought about this more.  Here's a brain dump:
>
> Here's how I'd expect these expressions to be executed internally, in
> gross pseudocode, ignoring for the moment the multimethod vaporware:
>
> $r = $a + $b;             # $a->add($a, $b, $r)
> $r = @a + $b;             # $t = @a->get_pmc(@a); $t->add($t, $b, $r)
> $r = $a + @b;             # $t = @b->get_pmc(@b); $t->add($a, $t, $r)
> $r = @a + @b;             # $t = @a->get_pmc(@a); $u = @b->get_pmc(@b); $t->add($t, $u, $r);
> @r = $a ^+ $b;            # Something that makes one-elment arrays and
>                           # uses add method on array object?  Or perhaps
>                           # error
> @r = @a ^+ $b;            # Does this distribute? If so,
>                           # @a->add(@a, $b, @r) else see above
> @r = $a ^+ @b;            # See above
> @r = @a ^+ @b;            # @a->add(@a, @b, @r), easy


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