lua-users home
lua-l archive

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

On 12/25/11 1:42 AM, HyperHacker wrote:
On Sun, Dec 25, 2011 at 02:37, Dimiter "malkia" Stanev<>  wrote:
-- Somewhat better version, that can work on multiple tables (environments),
rather than one... This way one can add, for example, the process
environment as table, and expand it there, or some last-minute workaround
table for missing keys.


I wrote a string interpolator a while ago, but the biggest problem I
found was locals and upvalues. There's no good way to look them up by
name. Maybe a preprocessor that replaces $(foo) with
"..tostring(foo).." (or whatever type of quotes are necessary for the
given string) would be a good way to fix that. (You could even do like
PHP and only do it for double-quoted strings.) Trouble then is it
doesn't work on strings generated at runtime, and doesn't permit more
complex expressions. (Mine for example allows crazy things like
"$(string.reverse $(blah))".)

Or I can just keep dreaming that someday Lua will provide a method to
look up variables in the current local scope by name... :~)

I'm working on writing some minimal build system, and way to expose variables, that are not even from lua, but describing projects, how they compile, etc. - and this mixed with the process environment.

Evaluation could be done, but don't see the reason yet. Might give a quick try for $() for eval, without trying to bring the locals :)