lua-users home
lua-l archive

Re: PiL3: typos

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 27/10/2013 17.00, Roberto Ierusalimschy wrote:
[...]
> 
> This is already in the errata [1]. (The errata has also a brief
> discussion about "memoization".)
> 
> [1] http://www.lua.org/pil/errata.html
> 
This time I checked in advance! :-)
At p.152, 3rd paragraph, the sentence:
"Everything that the module exports, such as functions and constants,
*it defines* inside this table, which works as a namespace."
doesn't sound clear to me. Should it be perhaps:
"Everything that the module exports, such as functions and constants,
*is defined* inside this table, which works as a namespace."
instead?
----------------------------------------------------------------
There is an incongruence between the reference manual and p.225, where
the 6th paragraph reads:
"The first argument to io.lines can be a file name or a file handle."
But there is no mention of this feature in the manual [1]. Moreover if I
try this in my 5.2.2 interpreter:
 local fh = assert( io.open "datafile" )
 for line in io.lines( fh ) do
 print( line )
 end
 fh:close()
I get the following error:
 bad argument #1 to 'lines' (string expected, got userdata)
This may be the reason why there is a seemingly spurious line in the
listing 22.1 on the next page. In the code the line:
 local f = io.input(arg[1]) -- open input file
seems useless, since `arg[1]` is opened by `io.lines(arg[1], BUFSIZE,
"*L")` in the subsequent for statement and `f` is not used anywhere else.
Am I missing something?
-- Lorenzo
[1] http://www.lua.org/manual/5.2/manual.html#pdf-io.lines
-- 
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments

AltStyle によって変換されたページ (->オリジナル) /