Re: object instance names generated on the fly?
Re: object instance names generated on the fly?
- Subject: Re: object instance names generated on the fly?
- From: Marcel Weiher <email@hidden>
- Date: Sat, 22 Mar 2003 17:20:04 +0100
for(my $i=0; $i < 10; $i++) {
${'myobject' . $i} = new Foo;
}
The result would be ten instances of Foo, named $myobject0,
$myobject1, etc.
This sort of thing is possible in Perl because variable names are
accessible at runtime. In fact, the entire name space is implemented
as a series of nested hash tables, which can be manipulated at run
time. If you iterate over the keys of the hash named "%Foo::", for
example, you'll get a list of all the names in package Foo.
yes you're right, that's exactly the type of thing i'm after
But that's just simulating an array (in a very roundabout way). Just
use an NSArray.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.