John Siracusa skribis 2004-12-03 14:46 (-0500): > Anyway, I thought it was interesting to see the ease of "forward > compatibility" for simple attributes touted as a feature of Python. I'd > like to tout it as a feature of Perl 6 too, because I also hate writing > getters and setters... :)
Of course it's a feature. Having lvalue attributes means you don't have to replicate all scalar lvalue methods to get all functionality without copying. IMO, This is even better than in Python, with its constant variables. Let me demonstrate: $foo.bar .= "foo" $foo.bar ~~ s:e/foo/bar/; $foo.bar.=reverse; my $quux := $foo.bar; $quux = 1; versus: $foo.set_bar($foo.get_bar ~ "foo"); $foo.set_bar(do { (my $temp = $foo.get_bar) ~~ s:e/foo/bar/; $temp }); $foo.set_bar($foo.get_bar.reverse); my $quux # ... ehm, right. Let's see. I think it's something like: will STORE { $foo.set_bar($_) } will FETCH { $foo.get_bar }; $quux = 1; Juerd