lua-users home
lua-l archive

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


On Sun, Dec 25, 2011 at 02:37, Dimiter "malkia" Stanev <malkia@gmail.com> 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... :~)

-- 
Sent from my toaster.