Re: Wish: variable_id()
- Posted by Kat <gertie at PELL.NET> Dec 31, 2002
- 423 views
On 31 Dec 2002, at 12:20, Andy Serpa wrote: > > It has been suggested before to add the ability to parse/execute strings > as Euphoria code, which would be terrific, but short of that, how about > variable_id(), which ought to be in the realm of possibility, plus we've > already got routine_id(), and it is lonely. > > The ability to look up variables by their names ala variable_id("x") > would make it trivial to make a user-created expression evaluator > without all sorts of code for assigning variables. Of course, along > with variable_id() we'd need a couple of extra functions to make > assignments & lookup values via id -- i.e. get_value(v_id) & > assign(v_id, new_value). Or maybe just make available a special array > of all variables accessible within the current scope as is done in some > languages. [ i.e. VAR_ARRAY[4] = new_value; find("x",VAR_ARRAY_NAMES), > etc. ] > > Unlike many suggestions for new features, which are shortcuts that might > make things easier but don't add new functionality to the language, this > would open up all sorts of new possibilities that currently are...well, > not possible. I had asked for that too, as well as getting the entire list of variable names. The answer was no. You can do this in Lua and mirc tho. It's rather important to know what you know, isn't it? Alternatively, you can use Jiri's (or others) associated lists, altho these get quite slow if you use large lists. Kat