develooper Front page | perl.datetime | Postings from January 2003

Set/Get methods

Thread Next
Rich Bowen
January 24, 2003 03:45
Set/Get methods
Message ID:
Someone who is watching the list more closely than I appear to be
pointed out to me that some discussion had occurred about get/set
attribute methods. I can't find that discussion, and don't feel like
searching for it at this time of the morning, and before coffee to boot.
Anyways, apparently some folks favor the idea of having separate get and
set methods for attributes? So I just wanted to pitch in my $0.02, for
the record. Having to call a different method to get and set the same
attribute is a hassle, and guarantees that people will get the API
confused in their branes.

$x = $obj->attrib; # Returns current value
$obj->attrib(12);  # Sets value to 12. Returns current value (now 12)
or, alternately, returns the old value - some people like that, but that
tends to confuse me.

This is trivial to implement (was there an argument?) and simplifies the

Now, if this matter never came up, and the whole episode was imagined,
then ignore me and move on your way. But I just wanted to note that I'm
opposed to having to call ->attrib_get and ->attrib_set as different

You may now go back to your regularly scheduled mailing list, and I will
try to keep up with the entire discussion.

Pilgrim, how you journey on the road you chose
To find out where the winds die and where the stories go
 --Pilgrim (Enya - A Day Without Rain)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About