John Siracusa:
# 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?

Please note that these are my best guesses; I'm not a Damian ;^).

#     $obj.colors('red', 'green', 'blue');
#
#     $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]?? ;)

$obj.colors[1]; #If {} and [] force a scalar context, the array return
                        #value of .colors will turn into an arrayref.

# 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' };

$obj.fruit=(apple => 'red', berry => 'blue');

#     # Change apple color, but leave the blue berry
#     $obj.fruit(apple => 'green');
#
#     print $obj.fruit('apple'); # green

$obj.fruit{apple}

# 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  }

BTW, I'm getting this headers thing too, from all @perl.org mailing
lists--not just p5p.  Ask, is this your department, and if so can you
fix it?

--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6

When I take action, I’m not going to fire a $2 million missile at a $10
empty tent and hit a camel in the butt.
    --Dubya

Reply via email to