lua-users home
lua-l archive

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


Howdy. Can anybody tell me if the code listing on page 221 near top of page in the Lua book is correct?

The line "luaL_checkstack(L, 1, "too many arguments");

I can only find lua_checkstack (no "L" in the middle) and it takes only 2 arguments. Since I also (oddly?) found a luaK_checkstack and a luaD_checkstack I thought I might be missing something.

Thanks,
Brett

----- Original Message ----- 
From: "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br>
To: <lua@bazar2.conectiva.com.br>
Sent: Friday, February 06, 2004 1:18 AM
Subject: RE: Calling a chunk by file name


> >this file i's build like this
> >
> >luac -o files.dat prog1.lua prog2.lua prog3.lua
> >
> >What I'm trying to do is to call, say, "prog2.lua", that it's in "files.dat".
> >
> >It's that possible?
> 
> No, because when you compile 3 Lua files together, luac fixes things so that
> when you run the precompiled code it executes all three files.
> 
> Try luac -l prog1.lua prog2.lua prog3.lua and see the main function.
> 
> Now, there is no real reason for this being as it is. It's just the simplest
> thing that is compatible with the old idea of dofile, before the loadfile days.
> If someone can argue that having different options for luac to select what to
> do in the created main, it can be done, but I don't think it'll be easy to come
> up with something simple that is consistent with the case of 1 file.
> 
> Right now, luac prog1.lua prog2.lua prog3.lua generates a main that is
> equivalent to
> 
> dofile"prog1.lua"
> dofile"prog2.lua"
> dofile"prog3.lua"
> 
> except that dofile is not called at all.
> 
> Note for instance that this ignores any values returned by the chunks. Like
> I said, it is easy to implement different mains, but it'll not be easy to
> do it consistently with the 1-file case.
> --lhf