Re: objarr [message #17071 is a reply to message #16982] |
Fri, 03 September 1999 00:00   |
Pavel Romashkin
Messages: 166 Registered: April 1999
|
Senior Member |
|
|
I agree that execution of a method on objarr of the same type would be
very nice to have. For instance, I tend to have related arrays of the same
type, let's say, IDLgrText (don't blame me for not having my own -
built-in works for me so far, this is how inflexible I am :-( ). It'd be
really handy to be able to do MyTextObjArr -> setProperty, color=[...]
without going through a loop. I disagree that array operations should be
disallowed for the sole reason being that an objarr can have different
object types. I'd much rather have it to be the programmer's
responsibility not to call a disallowed method on a heterogenious objarr
than not having it at all :-(
Cheers,
Pavel
bjackel@phys.ucalgary.ca wrote:
> Say I have a single object called Vector3, that allows nice things like
>
> mag= Vector3->magnitude()
> dot= Vector3->dotproduct(secondvector)
>
> and so on. Then assume I've got a whole pile of vectors
>
> pile= OBJARR(100)
> FOR indx=0,99 DO pile[i]= Vector3
>
> and want to manipulate them all at once
>
> magpile= pile->magnitude()
> % Object reference must be scalar in this context: PILE
> % Execution halted at: $MAIN$
>
> One foremost advantages of IDL is that logical groups of
> vector and matrix operations can be carried out with a
> single command. 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()
>
> Any comments or suggestions would be most welcome.
>
> Brian Jackel
|
|
|