For what it's worth...
Perl 6 classes will autogenerate accessors that return the underlying attribute itself as an lvalue:
class DogTag { has $.name is public; has $.rank is public; has $.serial is readonly; has @.medals is public; submethod BUILD ($id) { $.serial = $id }
method title () { return "$.rank $.name" } }
my $grunt = DogTag.new(71625371);
$grunt.name = "Pyle"; $grunt.rank = "Private";
print "$grunt.title ($grunt.serial)\n";
And Perl 6 supports "chaining" of accessors using $_ and the unary dot operator, not return values:
given $grunt { .name = "Patton"; .rank = "General"; push .medals, "Purple heart"; }
Hmm, that's very similar in spirit to the 'classic' form.
Will generated accessors be overridable? I can see how 'given' would be useful, but what if I wanted to say this:
$grunt.name( "Patton" ) .rank( "General" ) .add_medal( "Purple heart" );
And have you considered a twisted lvalue form like:
$grunt.name = "Patton" .rank = "General" .medals += ("Purple heart");
though that's prolly difficult to support.. ;)
-Steve