lua-users home
lua-l archive

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


On Sun, Jul 4, 2010 at 6:48 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> 2. Expansion of local variables in strings could be very useful.
> Global variable expansion is done trivially, of course. So, perhaps,
> use global variables in such code is justified (but that would inhibit
> functional decomposition in the scripts).
On Mon, Jul 5, 2010 at 7:55 AM, Vyacheslav Egorov
<mister.aleph@gmail.com> wrote:
> When I was writing utility scripts in Lua I quickly became annoyed by lack
> of variable expansion mechanism.
> So the first thing I introduced was a function expand which (just as it name
> suggests) expanded $-prefixed variables inside given string. It relied on
> debug functions to look for variables inside caller frame.

That's a recurring problem.  There are a few solutions in Lua, though
none are ideal:
http://lua-users.org/wiki/StringInterpolation .