lua-users home
lua-l archive

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


> upvalues do have their merits.
> 
> $ lua
> Lua 4.1 (alpha)  Copyright (C) 1994-2001 TeCGraf, PUC-Rio
> > function declare(name) setglobal( name, function() return %name..'!' end ) end
> > declare'bill'
> > declare'bert'
> > print(bert(),bill())
> bert!   bill!
> > 

Thanks, indeed that does work.  I had tried something along those lines,
but I was working with a global 'name', so:

    name = "xyzzy"
    setglobal( name, function() return %name..'!' end ) end

results in:

    error: global upvalues are obsolete;

Works nicely with the local / arg though.

Thanks also to Steve for the dostring() solution which also works.


Love, Light and Peace,
- Peter Loveday
eyeon Software