lua-users home
lua-l archive

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


It would be nice if Lua had a (psuedo?) table that gave the current value of
any identifier if indexed by that identifier, whether that's a local or not

Of course, someone will now reply and tell me it already exists.

Can you play games with __index and the function environment to get a table
that works like that? I can't seem to get my head around this today.

P.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of
askok@dnainternet.net


Passing the local variables as a kind-of identity matrix 
is not too bad:

local me= "asko"
local age= 36

print( "My name is $me and my age is $age."     % { me=me, 
age=age } )

print( "My name is ${me} and my age is ${age}."     % { 
me=me, age=age } )


Global values can be pointed to like such (unless the % 
operator wants to default fall-back to them):

print( "This is a global value: ${print}" % _G )