lua-users home
lua-l archive

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


I am looking for a way to expand a variable's contents when I
create a function, using setglobal().

For example, say I want to create a series of functions which
simply return their name with an exclamation mark appended to
it, for each one I might do:

    -- 'name' contains the name of the function I wish to create
    setglobal(name, function() return name.."!" end)

This declaration succeeds, but unfortunately when calling the
function 'name' refers to the current contents of the name variable,
not the contents at declaration.  Is there some way to force this
to be expanded, or the reference frozen, at declaration time ?

Thanks for your help,

Love, Light and Peace,
- Peter Loveday
eyeon Software