A lot of objects with name/value pair constructors often define a simple "80% of the time" use-case for which named argument you'd be wanting to set if you just passed a single one. E.g. IO::Socket::IP presumes a single IP is the PeerHost argument.
I'd imagine adding a single
unshift @_, "epoch" if @_ == 1
would be a pretty trivial and uncontentious patch.
I use the above at least a few times, plus doing things like simple calculations or counting string length, etc. "perl -dee" does not come with readline editing/history and requires you to type "p" to print out stuffs.
@tobez - being forced to use a named param there when it's obvious what you're passing is annoying, indeed; as LeoNerd says, I expect a patch to make the obviously sensible behaviour supported would be welcomed.
why not submit a patch?
A lot of objects with name/value pair constructors often define a simple "80% of the time" use-case for which named argument you'd be wanting to set if you just passed a single one. E.g. IO::Socket::IP presumes a single IP is the PeerHost argument.
I'd imagine adding a single
unshift @_, "epoch" if @_ == 1
would be a pretty trivial and uncontentious patch.
This is one of the reasons I always install "irb" (the Ruby REPL) on my systems. The Ruby version is:
I use the above at least a few times, plus doing things like simple calculations or counting string length, etc. "perl -dee" does not come with readline editing/history and requires you to type "p" to print out stuffs.
Devel::REPL has readline/history (shared with debugger :) ) and prints results too.
@Steven - you could also look at tinyrepl from Eval::WithLexicals:
@tobez - being forced to use a named param there when it's obvious what you're passing is annoying, indeed; as LeoNerd says, I expect a patch to make the obviously sensible behaviour supported would be welcomed.
No, you're not the only one. I do this too.
Playing Devil's advocate... at least it's consistent. All the constructors use named parameters.
I usually try this first:
I would prefer it, since it eliminates the redundant "epoch" but keeps the named paramaters.
DateTime is Autarch-ware, and therefore almost certainly crap.
Unless there is a better alternative, Autharch's DateTime is the best Perl has to offer.