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

assign opcodes

4 views
Skip to first unread message

Leopold Toetsch

unread,
Aug 8, 2003, 10:16:13 AM8/8/03
to P6I
I hopefully got the semantics of assign Px,Py right now. The LHS gets
the value of RHS, eventually morphing itself to the source type.

Anyway:

assign Px, {Iy,Sy,Ny}

are not needed IMHO, these end up as set_<type>_native and are identical
to set Px, {Iy,Sy,Ny}.

But we are missing keyed variants to set the value of some aggregate member:

assign(in PMC, in KEY, in PMC)
assign(in PMC, in INTKEY, in PMC)

with the 2 vtables assign_keyed and assign_keyed_int.

Comments welcome
leo

Togos

unread,
Aug 8, 2003, 3:05:23 PM8/8/03
to l.to...@nextra.at, perl6-i...@perl.org
> Anyway:
>
> assign Px, {Iy,Sy,Ny}
>
> are not needed IMHO, these end up as
> set_<type>_native and are identical
> to set Px, {Iy,Sy,Ny}.

Yes, but as we were discussing in the
Set vs. Assign thread, it makes more sense
to call them 'assign', as it morphs the
existing value (as 'assign Px, Py' does),
instead of simply copying a pointer
(as 'set Px, Py' does). Yay for consistancy.
If you want to get rid of opcode aliases,
perhaps it would be better to get rid of
the extra 'set's.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Benjamin Goldberg

unread,
Aug 8, 2003, 10:10:49 PM8/8/03
to perl6-i...@perl.org
Togos wrote:
>
> > Anyway:
> >
> > assign Px, {Iy,Sy,Ny}
> >
> > are not needed IMHO, these end up as
> > set_<type>_native and are identical
> > to set Px, {Iy,Sy,Ny}.
>
> Yes, but as we were discussing in the
> Set vs. Assign thread, it makes more sense
> to call them 'assign', as it morphs the
> existing value (as 'assign Px, Py' does),
> instead of simply copying a pointer
> (as 'set Px, Py' does). Yay for consistancy.
> If you want to get rid of opcode aliases,
> perhaps it would be better to get rid of
> the extra 'set's.

Out of curiosity, how does the word "assign" imply that it morphs an
existing value, and how does the word "set" imply that it copies a
pointer?

Obviously, in parrot as it is now, this is how it is, but what precisely
led to the choice of those two names?

--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Leopold Toetsch

unread,
Aug 9, 2003, 2:12:15 AM8/9/03
to Togos, perl6-i...@perl.org
Togos <chumps...@yahoo.com> wrote:
>> Anyway:
>>
>> assign Px, {Iy,Sy,Ny}
>>
>> are not needed IMHO, these end up as
>> set_<type>_native and are identical
>> to set Px, {Iy,Sy,Ny}.

> If you want to get rid of opcode aliases,


> perhaps it would be better to get rid of
> the extra 'set's.

Cleanup (get rid of assign Px, Ix) and renaming existing ops are clearly
separate steps. C<assign> is currently used in tests only AFAIK, while
C<set> is everwhere.
So while its rather simple to remove duplicate functionality, the final
layout needs more work.

leo

Togos

unread,
Aug 9, 2003, 12:42:34 AM8/9/03
to perl6-i...@perl.org
> Out of curiosity, how does the word
> "assign" imply that it morphs an
> existing value, and how does the word
> "set" imply that it copies a pointer?

Well, I suppose "set" was chosen just because
that seems to be the standard name for an
operation that copies a pointer. Then "assign"
was chosen just to be different from "set" :-)

But they actually do make a bit of sense in
my mind.

"set P1 to P2" sounds like you're replacing
P1 with P2. Which is what happens, since P1
and P2 are just pointers.

"assign to P1 P2"
This seems to imply that you're going to tell
P1 that it's having P2 assigned to it. Like
at work when you get an 'assignment'. They
don't actually change you're value (hopefully),
but just give you something to do. They
'assign' you a job.

Boss: "Bob, I'm going to assign you a desk."
Bob: "OK"

Boss: "Bob, I'm going to set you to a desk."
Bob: "What? You're replacing me witha desk?!"

(Well, that's what I would say if I was Bob ;) YMMV)

Bob would probably object to being morphed to
a desk, as well. Actually I think "morph" is
not quite as appropriate as "assign", as
"morph" sounds like you're going to change the
type of the thing, while "assign" seems to imply
that the thing can do whatever it wants with the
new value.

if you assign an integer to a PerlString, it's
still a PerlString. But if you morph a PerlString
into an integer, it sounds like you're changing
the PerlString itself into an integer.

Also, 'assign' may be used (well I don't know,
but this would make sense) on
objects that represent variables. When you
'assign' the variable a value, you don't
really change the variable, itself, as would
be implied by "morph".

<slight-subject-change>

Personally, I would like "=" to mean 'set', and
maybe "<-" do 'assign'. Probably because I'm
used to thinking of PMC registers as pointers,
and because the kind of languages that I'm
used to (Java, Python, Ruby) all treat variables
as pointers, so '=' just copies pointers. I
think that people probably do more setting than
assigning, anyway, so keeping the set operator
short is good for that reason, too.

"<-" even looks like 'put into', which is pretty
much what you're doing when you say "P1 <- 3".
Yeah. I like that :-D

Leopold Toetsch

unread,
Aug 9, 2003, 9:23:33 AM8/9/03
to Togos, perl6-i...@perl.org
Togos <chumps...@yahoo.com> wrote:
> if you assign an integer to a PerlString, it's
> still a PerlString.

No more. I don't know, if its correct. But the behavior now seems more
natural to me:

new P1, .PerlInt
set P1, 42
new P0, .PerlUndef
assign P0, P1 # LHS is PerlInt now

The dest has to be morphed into the RHS type, IMHO.

> Personally, I would like "=" to mean 'set', and
> maybe "<-" do 'assign'.

That's a true alternative and with no problems WRT backward
compatibility.

leo

Benjamin Goldberg

unread,
Aug 9, 2003, 8:32:03 PM8/9/03
to perl6-i...@perl.org

Leopold Toetsch wrote:
>
> I hopefully got the semantics of assign Px,Py right now. The LHS gets
> the value of RHS, eventually morphing itself to the source type.
>
> Anyway:
>
> assign Px, {Iy,Sy,Ny}
>
> are not needed IMHO, these end up as set_<type>_native and are identical
> to set Px, {Iy,Sy,Ny}.

Or else, "set Px, {Iy,Sy,Ny}" ought to create a new pmc, then use
set_<type>_native, with that new pmc as the target, and store that new
pmc into Px.

> But we are missing keyed variants to set the value of some aggregate
> member:
>
> assign(in PMC, in KEY, in PMC)
> assign(in PMC, in INTKEY, in PMC)
>
> with the 2 vtables assign_keyed and assign_keyed_int.

We can alway emulate assign semantics with set followed by assign. That
is:

$Ptmp = $Px[ y ]
assign $Pz, $Ptmp

Bleh.

> Comments welcome

Brent Dax

unread,
Aug 11, 2003, 7:46:44 PM8/11/03
to TOGoS, perl6-i...@perl.org
TOGoS:
# Personally, I would like "=" to mean 'set', and
# maybe "<-" do 'assign'.

I usually think of registers as variables with fixed names, so the Perl
6 part of my brain suggests:

$P0 = $P1 #assign
$P0 := $P1 #set

--Brent Dax <br...@brentdax.com>
Perl and Parrot hacker

"Yeah, and my underwear is flame-retardant--that doesn't mean I'm gonna
set myself on fire to prove it."

Benjamin Goldberg

unread,
Aug 11, 2003, 10:14:42 PM8/11/03
to perl6-i...@perl.org

Brent Dax wrote:
>
> TOGoS:
> # Personally, I would like "=" to mean 'set', and
> # maybe "<-" do 'assign'.
>
> I usually think of registers as variables with fixed names, so the Perl
> 6 part of my brain suggests:
>
> $P0 = $P1 #assign
> $P0 := $P1 #set

Which is why I suggested, when proposing renaming assign, set, and clone
to alias, mutate, create, that shorthand for alias (which is today's set
Px, Py and set Sx, Sy) be ":=", and shorthand for mutate (which is
today's assign) be "=".

0 new messages