Juerd wrote:
my $four := three;

Assuming you meant $three instead of three.

Indeed. Sorry.


my $five = 5;
$four = 4; # $one == 4 now?

No, $four (and thus $three, which it is bound to) is now 4. $three is a reference, which is a value, which is now *replaced* with the new value.

OK. Then you need to define the behaviour of referential values. In particular what does &infix<=><Scalar of Ref of Ref of Int,Int> do? I get from your remarks that you intend to treat it exactly like 'Scalar of Ref of Any' without dispatching to 'Ref of Int'. That means creating a new value 'Ref of Int' from the rhs, binding the Scalar and the Ref to it or some such.


Is that so? Are we going to walk the path of inefficiency where $foo++
is really actually literally just $foo = $foo + 1, throwing away the old
variable, assigning a new one?

Heck, no! The $foo++ means &postfix:<++>( $foo ) the second is &infix:<=><Any>( &infix:<+><Any,Int>( $foo, 1 ) ) either dispatched at runtime or optimized at compile if possible. How efficient that is compared to each other I don't know.


And will Perl 6 reference values rather than their containers, that is:
will \$foo differ when $foo gets a new value, just as in Python id(foo)
changes after foo += 1?

Depends on the definition of the semantics of 'Ref of Scalar of Any' versus 'Scalar of Any' versus 'Ref of Any' versus 'Scalar of Ref of Any'. My question was actually about the language level definition of *chains of references*!

1) Is the referene creation done with \, := and implicit in scalar context?
   Or do \ and := differ? And what's different with ::=?
2) Is derefencing still done with $ chains where you have to know how far
   to go? Is $$$$$$$foo still valid Perl 6 syntax?
3) How are Refs dispatched in comparison to Scalars, Arrays and Hashes?

Here is another attempt to pose my question with -> depicting an indirection.
After the declarations with my we have two chains:

$four -> $three -> $two -> $one -> 1
$five -> 5

Now what does $four = 4 mean? Dump the chain from $three downwards
and end up with

$four -> 4
$five -> 5

or go all the way down and just rebind $one and dumping the value 1

$four -> $three -> $two -> $one -> 4
$five -> 5

The next question was about how far down $$four goes and how rebinding
at that level works. If it goes one down and rebinds there we get:

$two -> $one -> 4
$four -> $three -> $five -> 5

BTW, Parrot could collapse chains of reference in a GC run
or as side effect of identity checks.


I certainly hope we still have mutable values by design and

In my head "mutable value" and "constant variable" sound funny.


Is your view of the world like Python or like Perl 5?

More like an any-junction of all languages supported by Parrot :)


Values have no identity in Perl 5. Containers (variables, named or
anonymous) do. That also means that even though $foo = 5 and $bar = 5,
\$foo != \$bar. In Python, with foo = 5 and bar = 5, that means id(foo)
== id(bar), but I don't like that at all.

Once again \$foo != \$bar just means a dispatch to &infix:«!=»<Ref,Ref> which might need to be different for PerlRef and PythonRef if the latter exists at all. The difficult thing for the Parrot folks is the mixed case! The homogenous cases are up to the languages. But for the mixed case some meta language level has to define semantics or the languages have to adapt from the inside out by explicit foreign knowlegde.


Regards, -- TSa (Thomas Sandlaß)



Reply via email to