Okay, so we've got these guys auto-created if we want:
method foo is lvalue { return $.foo }
(plus or minus the syntax) which lets us do:
$obj.foo = 5;
print $obj.foo;
So, what about simple array accessors?
$obj.colors('red', 'green', 'blue');
$obj.colors = ('red', 'green', 'blue');
$obj.colors = ['red', 'green', 'blue' ];
push $obj.colors, 'red', 'green', 'blue;
pop $obj.colors;
print $obj.colors[1] # @{$obj.colors}[1]?? $obj.colors->[1]?? ;)
Can/will such an accessor be auto-created?
How about hashes (or "pairs"?)
$obj.fruit(apple => 'red', berry => 'blue');
$obj.fruit = (apple => 'red', berry => 'blue');
$obj.fruit = { apple => 'red', berry => 'blue' };
# Change apple color, but leave the blue berry
$obj.fruit(apple => 'green');
print $obj.fruit('apple'); # green
Regardless of whether something like the above two examples can/will be
auto-created, what would those methods look like anyway? Would they simply
be:
method colors is lvalue { return @.colors }
method fruit is lvalue { return %.fruit }
How many of the examples with the code above support?
-John