Klaas-Jan Stol (via RT) wrote:
a code snippet like this:
the_value = new 'Type'
the_value = 42
is in my eyes not clear. It seems as if the first line creates an object,
and it seems to be discarded on the second line, as some value is assigned
to the_value.
The key thing to keep in mind is that '=' is not an operator in PIR,
it's just syntactic sugar for human convenience. Those two lines are
actually:
new the_value, 'Type'
set the_value, 42
These apply two simple rules of "An '=' followed by an opcode means the
result argument is the first argument to the opcode" and "Any other
'=' (that's not a sub or method call) is the 'set' opcode, and the
result argument is the first argument to 'set'".
The different behavior is a result of calling different opcodes. Each
individual opcode decides whether it has assignment or binding behavior.
Allison