On Tue, 16 Sep 2003, Steve Purkis wrote: > Hi all, > > With the help of others, I've been bashing out an 'accessors' pragma[1]: > > use accessors qw( foo bar baz ); > > There are two popular styles of accessor I'd like to support: > > # classic: > print "I set foo!" if $obj->foo( $a_value ); > > # chaining: > $obj->foo( $a_value ) > ->bar( $another_value );
This whole chained accessors thing is a definite perl-ism and will do you no favours with people for whom Perl is not a primary language. Possible return values for write-accessors: true/false undef/error message the previous value the new value [I would never have considered the object itself a valid return value until I saw Perl people doing it. I still don't.] > Question is: what style should be the default? I'm not looking for a > debate here, just some numbers. If you don't wanna post to the list, > reply to me directly. I tend to use a simple true/false, except in complex cases where I return undef or an error message. There's no point putting any effort into giving the programmer something he already has. All of the other options fall into this category [object, new value, previous value]. S. -- Shevek http://www.anarres.org/ I am the Borg. http://www.gothnicity.org/