I agree that there is an awkward-ness in the way accessors and mutators work in DateTime.pm, but one thin I'd like to keep note of is that $dt->set() should be preserved, if not only for performance's sake because set() can be used to set multiple fields all at once, reducing the amount of calculation.
If we do change the naming, I vote for
$dt->day; $dt->day(1);
But I'm not too annoyed about this particular naming thing...
--d
David Wheeler wrote:
On Jul 15, 2004, at 2:40 PM, Dave Rolsky wrote:
$d->day(1) and friends should be the equivalent of $d->set(day => 1) to make the interface consistent and obvious.
Hrm. I'm inclined to agree, I think. I like having separate accessors and mutators but DateTime's current model:
$d->day; # accessor $d->set_day(1); # mutator
Has a different naming convention for the two types of methods. I kind of like it, but only in environments where attributes are virtually always READ, and rarely WRITTEN. So maybe it should be:
# Perl-style $d->day; # accessor $d->day(1); # mutator
Or:
# Java-style $d->get_day; # accessor $d->set_day(1); # mutator
Thoughts?
David
