Re: [PATCH] add -p: import Term::ReadKey with 'require'
- From
Jeff King <peff@peff.net>
- Date
- Feb 7, 2009, 04:54 UTC
- Message-ID
- <20090207045401.GA21135@sigill.intra.peff.net>
- In-Reply-To
- <200902070021.18928.trast@student.ethz.ch>
On Sat, Feb 07, 2009 at 12:21:13AM +0100, Thomas Rast wrote:
Show 6 quoted lines
> > (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.
-Peff