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