grabbing value of a variabe by its name?
Ragnar Hojland Espinosa
ragnar at linalco.com
Thu Jul 25 14:49:36 UTC 2002
On Thu, Jul 25, 2002 at 07:09:51AM -0800, Alan Kay wrote:
> I think the construct that is most like you are looking for would be
> to type the following into a workspace and execute them with a "cmd
> (or alt) d":
>
> foo _ 'hello'.
> bar _ 'world'.
> baz _ { foo. bar}.
>
> If you then type
>
> baz
>
> and execute this with a "print it" -- a "cmd (or alt) d", then you will see
>
> #('hello' 'world')
We're on different wavelengths or I'm a bit obtuse today ;) That would be
what I was looking for if there was a way to examine the array and figure
out the 'hello'--foo relation. Or is there a way?
I'll restate my problem again.
$a = "hello";
$b = "world";
$c = "a";
print $$c; # references $a, and therferoe prints hello
$c = "b";
print $$c; # and now prints world
That is: find the value of a variable, referencing that variable by the
means of a string with its name.
--
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
|