HaloO,
Yuval Kogman wrote:
IMHO definately autovivify
* @foo[$idx] := $var;
my @bar = @foo;
$var = $new_var;
# @foo[$idx] and $var are now $new_var, but @bar is unchanged, right?
Yes, I agree. But we do need a way in the middle. Right now we have:
@bar := @foo; # array container aliased, so all nested
containers are shared
@bar = @foo; # array structure duplicated, elem containers
duplicated
but no way to say all the elements are the same, but the structure
isn't. Maybe this works, but I don't think so since assignment isn't
an operator, but a syntactic construct (i think):
Sorry, I believe everything is an operator---or actually operators
are Code subtypes with syntactic sugar. But some operators are usually
not dispatched because the type system manages to produce the same
effect as a real dispatch. But that is an implementation issue.
Conceptually I like to define the semantics of Perl6 in terms of type
and dispatch.
@bar >>:=<< @foo;
That is calling a ternary meta op that receives three args: the
two Arrays and a Code. And since list binding is so common assignment
of lists is simply overloaded in standard Perl6, thus
($foo,$bar) = (1,2);
"expands" to
($foo,$bar) >>=<< (1,2);
--
$TSa.greeting := "HaloO"; # mind the echo!