lua-users home
lua-l archive

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


On Sat, Apr 5, 2014 at 1:23 PM,  <tonyp@acm.org> wrote:
> OK, I see the problem, there was an extra dot in your match string.  After
> removing it works in all but the redirected case, which is how my editor
> runs it when pressing the related F-key.

mea culpa!  It's true that this is not as flexible as a built-in solution.

Using the debug library could tell you exactly the current name of the
script, so that

if debug.getinfo(1,'S').short_src == 'mod.lua' then
---
end

should work - (actually tested it this time ;))

That's rather verbose, but could be wrapped up as a requireable module

if require 'this_mod' 'mod.lua' then

end

where this_mod.lua returns a suitable function.

Since it _can_ be done with Lua, and a robust solution can be made
into a module, such a feature is unlikely to ever get baked into the
language.  Lua provides mechanism, not policy...