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

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

From
Thomas Rast <trast@student.ethz.ch>
Date
Feb 6, 2009, 23:21 UTC
Message-ID
<200902070021.18928.trast@student.ethz.ch>
In-Reply-To
<20090206203037.GB19959@coredump.intra.peff.net>
Jeff King wrote:
Show 12 quoted lines
> I believe it is fine. The tricky thing is that perl's parsing is
> dependent on what functions have been defined. So it is OK to say
> 
>   ReadKey 0;
> 
> if a subroutine ReadKey has been defined, but otherwise it generates a
> warning about using the bareword as a function. However
> 
>   ReadKey(0);
> 
> parses unambiguously, so it is always OK, even if no subroutine has yet
> been defined.

Ok, that explains a lot. I always thought Perl had a syntax influenced somewhat by the functional programming languages, where the parentheses are usually optional. Clearly not so.

> (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.

Thanks for the review!
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Jeff KingNext: Jeff King
Message 6 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.