in reply to Re: OO design: returning string and/or special value
in thread OO design: returning string and/or special value
I'm trying to go with the good old Larry Wall-ism and "make the easy things easy, and the hard things possible". I need the basic string representation 95% of the time, so making the caller remember to write $obj->method->{string} (hashref) or $obj->method->string (object return) or similar is the sort of thing I'm trying to steer away from if reasonably possible.
I grant you wantarray can occasionally be mildly surprising in certain edge cases, but I disagree that one should always steer clear of it. In my particular case I don't see how different contexts would confuse an average Perl programmer to any significant degree, even if they don't RTFM. If you want to explain your objection to wantarray in this case, though, I'd be grateful for another perspective on that! See my reply to stevieb for some example code.
if you don't want to require the caller of your method to provide params (?!)
What's surprising about a method without params? Or were you just emphatically confirming whether my method did or did not require params? (It doesn't).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: OO design: returning string and/or special value
by 1nickt (Canon) on Oct 08, 2019 at 00:13 UTC |