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

Home » Public Forums » archive » Operator precedence
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Operator precedence [message #20615] Mon, 10 July 2000 00:00
Harvey Rarback is currently offline  Harvey Rarback
Messages: 24
Registered: September 1998
Junior Member
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?

Thanks.
--Harvey

_______________________________Example Code___________________________________

pro obj2__define
obj2 = {obj2, data:0}
end

;*********************************************************** *****************

function obj1::init
self.obj2 = obj_new('obj2')
return,1
end

;*********************************************************** *****************

pro obj1__define
obj1 = {obj1, obj2:obj_new()}
end

;*********************************************************** *****************

pro obj1::test

obj1 = self
; next line produces % Expression must be a structure in this context: <No name>
;print, obj1.obj2.data

; next line prints data but produces
; % Temporary variables are still checked out - cleaning up...
print, (obj1.obj2).data

;next line produces % Expression must be a structure in this context: OBJ2.
;print, obj1.(obj2.data) ;

end

;*********************************************************** *****************

pro test_has_a

obj1 = obj_new('obj1')
obj1->test

end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Genetic Algorithm in IDL?
Next Topic: Genetic Algorithm in IDL?

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

Current Time: Wed Oct 08 17:06:24 PDT 2025

Total time taken to generate the page: 0.00523 seconds