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

Home » Public Forums » archive » Re: Modifying Arrays and Structures in HASH's (hint: you can't)
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: Modifying Arrays and Structures in HASH's (hint: you can't) [message #79669] Fri, 23 March 2012 16:07 Go to previous message
JDS is currently offline  JDS
Messages: 94
Registered: March 2009
Member
> The problems shows up in structures and array indices if they are used in the way written above:
>
> IDL> print,(h['a'])[1]
> -1
> IDL> (h['a'])[1]=99
> % Expression must be named variable in this context: <INT Array[3]>.
> % Execution halted at: $MAIN$
>
> And that is all fault of the parser's weird use of values instead of references on qualified names. Which, for that reason, and for breaking the least surprise principle, should be changed in a future version (a compile_opt, or a new file extension, to keep compatibility).
>
> But I think that the multiple indices for arrays approach could easily be applied to structures, just making a small change to the overloadbracketsleftside method. I may write a small derived class for that purpose. In that way, it would be possible to do
>
> h['a','b']=2

Interesting. I wonder if this would this be fully as flexible as the structure dereference, which can retrieve and assign arrays:

IDL> a=replicate({b:randomu(sd)},100)
IDL> help,a.b
<Expression> FLOAT = Array[100]
IDL> a.b=findgen(100)

It would need to do so for the POLS. It certainly loses points for lack of semantic consistency. And it creates another more extreme category of, e.g. the "structure member variables cannot be passed by reference" rule.

Thanks,

JD
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Coyote graphics and resizeable draw widgets
Next Topic: Coyote graphics and GDL 0.9.2 (problem)

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

Current Time: Fri Oct 10 22:03:49 PDT 2025

Total time taken to generate the page: 1.27825 seconds