So, basically you are saying you don't think the method names are picked appropriately?
No, that's not what I'm saying.
Perhaps you'd prefer Hungarian notation for methods?
I would prefer that people stop using [and writing, and chaining] methods that return the object they operate on.
| [reply] [Watch: Dir/Any] |
I would prefer that people stop using {and writing, and chaining} methods that return the object they operate on.
I would prefer having Natalie Portman as a girlfriend (having just seen Closer, the subject is fresh on my mind, sorry).
But seriously...
I find mutators-that-return-$self to be very handy. I've tried to understand your complaint. In the Alpaca book, I talk about mutators that return:
- the new value (usually accidentally the default),
- the previous value (ala umask),
- $self (as in this discussion),
- a success/fail code (for things that might fail being set),
- or an unspecified result.
I've seen it all. All have been useful over time. The real thing is to be
as consistent as you can, and don't change it once you've committed.
My File::Finder::Steps methods actually return a cloned-and-modified-$self, permitting a chaining of sorts. I find the notation very
natural there. If I had to do it some other way, I'd probably scream. {grin}
So, perhaps you are not comfortable with mutators returning $self, but they're probably here to stay. My guess is that you got burned once, and now you're out for blood. Chill. {grin}
| [reply] [Watch: Dir/Any] |
| [reply] [Watch: Dir/Any] |
$foo->bar($x)->baz($y)
can be either
$foo->bar($x);
$foo->baz($y); # same object
or
my $bar = $foo->bar($x);
$bar->baz($y); # different object
which is the ambiguity he's talking about.
ihb
See perltoc if you don't know which perldoc to read!
Read argumentation in its context!
| [reply] [Watch: Dir/Any] [d/l] [select] |