lua-users home
lua-l archive

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

Thanks, Peter.

This has the great benefit that also the name of the script itself is included (as 'select(1,...)'). This allows scripts to know where they reside, and then to launch subscripts in the same dir.

I hope the Lua authors keep it that way..


4.9.2004 kello 18:20, Peter Shook kirjoitti:

 Good work guys, replacing arg with ... is a great idea.

It makes code easier to read:

   function printf(...) io.write(string.format(...)) end

And being able to access the args passed to the function returned by loadstring/loadfile is really great too.

Here is a modified version of dofile for those who can't wait to play with this feature:

static int luaB_dofile (lua_State *L) {
 const char *fname = luaL_optstring(L, 1, NULL);
 int n = lua_gettop(L);
 if (luaL_loadfile(L, fname) != 0) lua_error(L);
 lua_insert(L, 1);
 lua_call(L, n, LUA_MULTRET);
 return lua_gettop(L);

$ cat x.lua


$ bin/lua
Lua 5.1 (work1)  Copyright (C) 1994-2004 Tecgraf, PUC-Rio

x.lua   1       2       3


- Peter

MSN® Calendar keeps you organized and takes the effort out of scheduling get-togethers. prem&xAPID=1994&DI=1034&SU= enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.