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

Home » Public Forums » archive » Re: Broken hash init()
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
Re: Broken hash init() [message #73182] Wed, 27 October 2010 16:18 Go to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Oct 27, 8:57 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> I just noticed that the init method is not properly creating hashes
> from structures on some situations:
>
> IDL> a={b:list(1,2)}
> IDL> print,a
> {<ObjHeapVar1(LIST)>}
> IDL> print,a.b
>        1
>        2
> IDL> h=hash(a)
> IDL> print,h
> B:        1
>
> Or,
>
> IDL> a={b:[1,2]}
> IDL> print,a
> {       1       2}
>
> IDL> h=hash(a)
> IDL> print,h
> B:        1
>
> But this works:
>
> IDL> a={b:9,c:[5,8]}
> IDL> print,a
> {       9       5       8}
>
> IDL> h=hash(a)
> IDL> print,h
> B:        9
> C:        5       8

Trying to get around that problem, I encountered the same problem
because I forgot about the bug with foreach on string arrays. So
perhaps that is also causing the problem with hash::init():

IDL> a={a:[1,2]}
IDL> h=hash()
IDL> foreach tag,tag_names(a),i do h[tag]=a.(i)
IDL> print,h
A: 1

Using a for loop instead of the foreach, it works normally:

IDL> tn=tag_names(a)
IDL> for i=0,n_elements(tn)-1 do h[tn[i]]=a.(i)
IDL> print,h
A: 1 2
Re: Broken hash init() [message #73247 is a reply to message #73182] Thu, 28 October 2010 16:49 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Oct 27, 9:18 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Oct 27, 8:57 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
>
>
>
>
>
>> I just noticed that the init method is not properly creating hashes
>> from structures on some situations:
>
>> IDL> a={b:list(1,2)}
>> IDL> print,a
>> {<ObjHeapVar1(LIST)>}
>> IDL> print,a.b
>>        1
>>        2
>> IDL> h=hash(a)
>> IDL> print,h
>> B:        1
>
>> Or,
>
>> IDL> a={b:[1,2]}
>> IDL> print,a
>> {       1       2}
>
>> IDL> h=hash(a)
>> IDL> print,h
>> B:        1
>
>> But this works:
>
>> IDL> a={b:9,c:[5,8]}
>> IDL> print,a
>> {       9       5       8}
>
>> IDL> h=hash(a)
>> IDL> print,h
>> B:        9
>> C:        5       8
>
> Trying to get around that problem, I encountered the same problem
> because I forgot about the bug with foreach on string arrays. So
> perhaps that is also causing the problem with hash::init():
>
> IDL> a={a:[1,2]}
> IDL> h=hash()
> IDL> foreach tag,tag_names(a),i do h[tag]=a.(i)
> IDL> print,h
> A:        1
>
> Using a for loop instead of the foreach, it works normally:
>
> IDL> tn=tag_names(a)
> IDL> for i=0,n_elements(tn)-1 do h[tn[i]]=a.(i)
> IDL> print,h
> A:        1       2

I just verified that this is fixed in 8.0.1. Which makes this the
shortest duration I ever experienced a bug.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 8.0.1 Bugs Fixed
Next Topic: Re: IDL 8.0.1 Bugs Fixed

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

Current Time: Thu Oct 09 15:55:55 PDT 2025

Total time taken to generate the page: 1.59874 seconds