grabbing value of a variabe by its name?

Andrew C. Greenberg werdna at mucow.com
Fri Jul 26 11:02:57 UTC 2002


There are a kazillion ways to accomplish this, both with and without 
reflection.  Ragnar's two examples aren't comparable (for example, the 
first requires the use of the phrase asQuotedPostgres, but the second 
does not, and does not adequately characterize whether the names are 
variables or instance variables or string parameters; the second does).  
Clearly, you can implement the second class trivially and without 
introspection.  Moreover, you can make a more flexible class with 
introspection if you like as well.

So what are the requirements?

On Friday, July 26, 2002, at 05:33 AM, Ragnar Hojland Espinosa wrote:

> If I got to choose which code to maintain, this:
>
> execute 'insert into table1 
> (firstName,lastName,position,address,zip,country) values (',
>         firstName asQuotedPostgres,',',
>         lastName asQuotedPostgres,',',
>         position asQuotedPostgres,',',
>         address asQuotedPostgres,',',
>         zip asQuotedPostgres,','
>         country asQuotedPostgres,')'.
> 	"ad nauseum"
> 			
> or this:
> 			
> fields _ SQLFields new: #(firstName lastName position address zip 
> country).
> execute 'insert into table1 (', fields asNames, ') values (', fields 
> asValues, ')'.





More information about the Squeak-dev mailing list