Re: objarr [message #17075 is a reply to message #16982] |
Fri, 03 September 1999 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
In article <MPG.1238930f48dc31b9898da@news.frii.com>
davidf@dfanning.com (David Fanning) writes:
>
> bjackel@phys.ucalgary.ca (bjackel@phys.ucalgary.ca) writes:
>
>> Am I correct in fearing that the only
>> way to get what I want is with something like this?
>>
>> magpile= DBLARR(N_ELEMENTS(pile))
>> FOR indx=0,N_ELEMENTS(pile)-1 DO magpile[indx]=
>> pile[indx]->magnitude()
>
> I'm afraid so. :-(
And I don't blame RSI for making it so. Just think about
it - an object array can be pointing to as many different
object types as the number of elements. There's no guarantee
that all of them have the particular method in question.
This goes for procedure methods as well as function methods.
Further, even if all the objects are of a single type,
a function method may return wildly different types of
results, depending on the internal state of the object!
So, there's no way for IDL to guess the type of array
needed to store the result.
OK, so there are ways to circumvent this, like determining
the type after all calls have been made. But, the scenario
also introduces a tricky problem with e.g. error reporting.
I guess you'd only get messages like
% Attempt to call undefined method: 'BLAH::MAGNITUDE()'
and various type conversion errors..
But I agree, it's annoyingly different from what we're used
to.
Regards,
Stein Vidar
|
|
|