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

Home » Public Forums » archive » Re: pointer to structures
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: pointer to structures [message #19541 is a reply to message #19540] Wed, 05 April 2000 00:00 Go to previous messageGo to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
"J.D. Smith" wrote:
>
> "Liam E.Gumley" wrote:
>>
>> "J.D. Smith" wrote:
>>> With time, you will get used to these semantics. They seem arcane, but
>>> eventually it becomes somewhat readable to the experienced eye. Of course, I've
>>> struggled with statements like:
>>>
>>> HEADER=*(*(*self.DR)[sel[i]].HEADER)
>>
>> I neglected to provide an example of why simplified pointer and
>> structure referencing is desirable. Thanks for the help JD!
>>
>> ;-)
>>
>> Cheers,
>> Liam.
>
> But then you have to ask yourself which is worse, the confusing string above, or
> the explicit:
>
> drs_ptr=self.DR
> drs=*drs_ptr
> this=drs[sel[i]]
> hd_arr_ptr=*this
> hd=*hd_arr_ptr
>
> repeat this about 5000 times throughout your application, and you begin to
> appreciate the terse form above. Especially if you're passing some part of the
> nested data to a routine by reference... intermediate variables require you to
> remember to assign them after use (everybody remember
> widget_control,stash,set_uvalue=state,/NO_COPY?).

I would not repeat this code 5000 times. I'd find a way to encapsulate
it in a function where I can include comments and error checking (e.g.
Is this a valid pointer? Does it point to a defined variable?). In these
cases I find it much better to create a 'put' and 'get' function pair
where all the de-referencing is handled inside the function. That way I
can use the 'put' and 'get' modules all over the place, and if I change
the way the pointers/structures are nested, I only have to change the
code in two places (inside the functions).

Cheers,
Liam.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: get variables name
Next Topic: Re: Speed up movie in object graphics.

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

Current Time: Wed Oct 08 17:44:31 PDT 2025

Total time taken to generate the page: 0.00413 seconds