grabbing value of a variabe by its name?

Ragnar Hojland Espinosa ragnar at linalco.com
Thu Jul 25 15:17:06 UTC 2002


On Thu, Jul 25, 2002 at 05:01:34PM +0200, Joern Eyrich wrote:
> I think what Ragnar wants is not the values *instead of* the names, but
> *both* of them - kind of like a Dictionary with its keys and values - but
> ... well ... without the Dictionary ;-)    
>
> he wants to put the names of variables into an object and then be able to ask it
> 1) for a list of the variable names
> 2) for a list of the corresponding values
> 
> Ragnar, did i get that right?

Right!

> I think this is not easy to do cleanly.
> 
> for this
> > fields _ SQLFields new: #(var1 var2 var3).
> > execute 'insert into table1 (', fields asNames, ') values (',
> >         fields asValues, ')'.
> to work, SQLFields' methods would have to reach into the method execution
> contexts of their senders or access other objects' instance methods by name,
> as far as I can see.  

Context is the other part of the problem, yes, but I got ways around that.

> I guess using a Dictionary would be the cleanest solution (that comes to
> my mind, anyway).

A Dictionary would be nice if there was a way to do the at/put in the same
message.  But lines of (at: 'field' put: field;) hurt my sensibility ;)

-- 
Ragnar Hojland - Project Manager
Linalco "Especialistas Linux y en Software Libre"
Tel: +34-91-5970074 Fax: +34-91-5970083



More information about the Squeak-dev mailing list