[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: do I really need to use loops on objects?
- Subject: Re: do I really need to use loops on objects?
- From: bjackel(at)phys.ucalgary.ca
- Date: Wed, 01 Dec 1999 12:01:04 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Calgary
- References: <38447341.28FBAACB@hotmail.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:17570
Brad Gom wrote:
> It seems odd to me that I can't treat object arrays with the same
> elegance that is possible with all other array types. If I have a large
> list of objects of the same type, and I want to call the same method on
> each of them, do I really have to use a for loop? Wouldn't it be more
> consistent with the IDL philosophy to write: object_array->method()
> instead of: for i=0,10 do object_array[i]->method()
I agree completely, but most people on this group don't appear to.
The counter argument seems to be that an object array can contain
different kinds of objects, so you can't be sure that any particular
method will work for every element of the array. While true, this
seems (to me) to be a reason why object arrays should contain only
similar elements *JUST LIKE EVERY OTHER IDL ARRAY TYPE*. If you
want different kinds of objects wrapped up together then use an
array of pointers, or a structure with different object members.
However, it is unlikely that RSI will make any significant change
to object arrays, so we might as well get used to more loops. Ugh.