Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setref a misnomer?

16 views
Skip to first unread message

Sam Ruby

unread,
Nov 2, 2004, 1:21:37 PM11/2/04
to perl6-i...@perl.org
I just spent some time debugging a problem which turned out to be due to
the "set" operator not doing what I expected (i.e., calling pmc_set).
In retrospect, what set id doing is perfectly defensible, but "setref",
as implemented by PerlScalar, remains counter intuitive, at least to me:

.sub main @MAIN
$P0=new PerlInt
$P0=1

$P1=new PerlInt
set $P1, $P0

$P2=new PerlInt
setref $P2, $P0

$P0=2

print "$P1 = "
print $P1
print "\n"

print "$P2 = "
print $P2
print "\n"
.end

- Sam Ruby

Leopold Toetsch

unread,
Nov 3, 2004, 4:54:40 AM11/3/04
to Sam Ruby, perl6-i...@perl.org
Sam Ruby <ru...@intertwingly.net> wrote:
> I just spent some time debugging a problem which turned out to be due to
> the "set" operator not doing what I expected (i.e., calling pmc_set).
> In retrospect, what set id doing is perfectly defensible, but "setref",
> as implemented by PerlScalar, remains counter intuitive, at least to me:

Yep. The C<setref> opcode is intended to set a reference inside a
reference type, like Ref or SharedRef. The implementation of
perlscalar's setref is the old "assign the RHS value" behavior.

We have to cleanup classes.

> - Sam Ruby

leo

0 new messages