lua-users home
lua-l archive

Re: First line of Lua chunk

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


On 22 August 2013 07:52, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> In that part of the manual, script would probably be better than chunk.
I agree, because a typed command in the standalone interpreter does
form a chunk, and yet:
Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
> #ignore
stdin:1: unexpected symbol near '#'
> But note that skipping the first line if it begins with # is done by
> luaL_loadfilex (and so luaL_loadfile, luaL_dofile, and require); it is
> not a feature restricted to the standalone interpreter.
Ah, so perhaps it should say it skips the first line of a _file_...
When I read Dirk's first message, the first thing I tried was:
local fn, err = loadstring([[#ignore
print("hello")
]])
if fn then
 fn()
else
 print(err) --> [string "#ignore..."]:1: unexpected symbol near '#'
end
but now I see that loadfile and loadstring behave differently in this regard.
-- Hisham

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