Re: Auto-creation of simple accessors (was: Perl 6 -

2001-10-30 Thread John Siracusa
On 10/30/01 5:12 PM, Damian Conway wrote: >> # Change apple color, but leave the blue berry >> $obj.fruit(apple => 'green'); > > No. You want: > > $obj.fruit{apple} = 'green'; Hm, I think I'll be writing arg-type versions of that one because I'm not too comfortable with exposing the fac

Re: Auto-creation of simple accessors

2001-10-30 Thread Damian Conway
John icked: > > # # Change apple color, but leave the blue berry > > # $obj.fruit(apple => 'green'); > > # > > # print $obj.fruit('apple'); # green > > > > $obj.fruit{apple} > > Icky, looks "unencapsulated" to me :) [For the benefit of those playing alon

Re: Auto-creation of simple accessors (was: Perl 6 -

2001-10-30 Thread Damian Conway
John asked: > So, what about simple array accessors? Writing: class Demo; my @.colors is public; gives you: > $obj.colors('red', 'green', 'blue'); No. $obj.colors() takes no arguments. > $obj.colors = ('red', 'green', 'blue'); Yes. > $obj.color

Re: Auto-creation of simple accessors (was: Perl 6 -Cheerleaders?)

2001-10-30 Thread John Siracusa
On 10/30/01 12:13 PM, Brent Dax wrote: > John Siracusa: > 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=('r

Re: Auto-creation of simple accessors (was: Perl 6 - Cheerleaders?)

2001-10-30 Thread Brent Dax
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;

Re: Auto-creation of simple accessors (was: Perl 6 -Cheerleaders?)

2001-10-30 Thread 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? $obj.colors('red', 'green', 'blue'); $obj.colors = ('red', 'green