comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Operator precedence
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Operator precedence [message #20610 is a reply to message #20606] Mon, 10 July 2000 00:00 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Harvey Rarback wrote:
>
> Folks,
>
> I have a couple of questions regarding operator precedence. From this newsgroup
> and some experimentation I believe the following statement is true:
>
> Structure field extraction and array indexing have equal precedence, higher than
> pointer dereference but lower than parentheses to group expressions.
>
> Is this statement true?
>
> So for nested structures struct1.struct2.data produces the same result as
> (struct1.struct2).data as expected. However, for nested objects (example code
> appended) these rules don't seem to apply:
>
> obj1.obj2.data produces an error
> (obj1.obj2).data produces the expected result, along with the infamous
> % Temporary variables are still checked out - cleaning up...
>
> Can some kind soul enlighten me about this behavior?
>

You have found a bug in IDL's object data encapsulation code, which likely
arises from the internal data-storage equivalence of structures and object heap
data.

As David points out, RSI made the (dubious) choice of enforcing full
encapsulation... object instance data is available directly only within the
methods of its class. So by all rights, this should not work at all, and you
should get the error you would have if tried from the command line: "% Object
instance data is not visible outside class methods."

I've found you can access the full data without error or warning if you use two
steps:

o=obj1.obj2
print,o.data

Presumably IDL is getting confused about which type of object it is dealing with
in relation to the method affiliation. Since objects and structures share so
much in common, RSI likely had to append encapsulation functionality with no
doubt some interesting hackery. I strongly recommend against relying on this
feature, since they are quite clear about: "only allowing access to an object's
instance data via that object's methods," and will likely fix it in future
releases. So, like the rest of us, you'll be stuck writing "GetProperty"
methods ... but at least we now have "_REF_EXTRA" for implementing these
correctly.

JD

--
J.D. Smith /*\ WORK: (607) 255-6263
Cornell University Dept. of Astronomy \*/ (607) 255-5842
304 Space Sciences Bldg. /*\ FAX: (607) 255-5875
Ithaca, NY 14853 \*/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Object Graphics Selection
Next Topic: Re: Genetic Algorithm in IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 16:55:55 PDT 2025

Total time taken to generate the page: 1.44081 seconds