NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
On method chaining (Score:3, Interesting)
In my new Alpaca book [oreilly.com], I argue that for a getter/setter method, there are arguments in favor of any one of four return values from the setter method:
- a simple true/false status (yes I was able to set this),
- the newly set value, turning the setter into an immediate getter as well,
- the previous value (ala umask and single-arg select), allowing flip-flop settings trivially, or
- the object itself, allowing for chained settings.
For anything but the first, a die has to be used to signal error.As long as it's documented, it's fine. Don't demand consistency. Any one of these four returns is fine.
Reply to This