git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 7, 2009, 07:50 UTC
Message-ID
<7v8woiznx3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090207045401.GA21135@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 26 quoted lines
> On Sat, Feb 07, 2009 at 12:21:13AM +0100, Thomas Rast wrote:
>
>> > (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.
Previous: Jeff King
Message 8 of 8 in “add -p: prompt for single characters”
  1. 3/4 add -p: prompt for single charactersThomas Rast, Feb 5, 2009
  2. 4/4 add -p: print errors in separate colorThomas Rast, Feb 5, 2009
  3. Jeff KingFeb 6, 2009
  4. add -p: import Term::ReadKey with 'require'Thomas Rast, Feb 6, 2009
  5. Jeff KingFeb 6, 2009
  6. Thomas RastFeb 6, 2009
  7. Jeff KingFeb 7, 2009
  8. Junio C HamanoFeb 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.