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 a sidenote.. (Score:1)
history_sizeinstead ofhistoryto avoid confusion. but i agree what you have said.Re: (Score:1)
Most of the time, the method is used to get the whole history as an array.
To give a more concrete background, I was working with the
GetHistorymethod fromTerm::ReadLine::Gnu,Term::ReadLine::PerlandTerm::ReadLine::Zoidwhen used byShell::Base. That said, instead of trying to convince all involved authors to change code or/and documentation, I tried to work with the contrived and actual API.I agree that introducing a
GetHistorySizemethod would eliminate instantly the problem associated to the ovugh! use "wantarray"! (Score:2)
Ugh! You really have two return values, so say so:
sub history { shift; return wantarray ? reverse @history : scalar @history; }This saves the extra work of reversing something that you don't need to reverse.sort too (Score:1)
I'd say that in application code 97.21% (plus/minus
So there really is a need for a Perl::Critic plugin that warns against "return CALL_TO_CONTEXT_AWARE_FUNCTION" where the context of the caller leaks into the sub and causes this severe action-at-a-distance.
(meta: five timeouts posting this)