Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] add -p: import Term::ReadKey with 'require'

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:07

Jeff King [off-list ref] writes:
On Sat, Feb 07, 2009 at 12:21:13AM +0100, Thomas Rast wrote:
quoted
quoted
(note that you could also skip the import and just call
Term::ReadKey::ReadKey by its full name).
I tried that but couldn't get either Term::ReadKey::ReadKey or
Term::ReadKey->ReadKey to work.  In retrospect, I suppose it requires
parentheses too.
Right, you would still need the parentheses. But note that the second
syntax (with the "->") would always be wrong. The "::" syntax just says
"find this name not in the current namespace, but in this absolute
namespace I am giving you". But "X->Y" is actually a syntactic shorthand
for "look up X::Y (or Z::Y, where Z is the blessed package of X), and
then call X::Y(X, @_)".

Which makes sense for object-oriented stuff. You get the object or the
classname as the first parameter to a method. But for a regular package
function, you would be calling

  Term::ReadKey::ReadKey('Term::ReadKey', 0)

which of course makes no sense.

But I think doing the import makes more sense (and is how Term::ReadKey
is intended to be used), so the patch you posted is best.
Ok, will queue.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help