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

Home » Public Forums » archive » Re: When you can't concatenate structures like you expect....
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: When you can't concatenate structures like you expect.... [message #15521] Mon, 24 May 1999 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
Paul van Delst wrote:
>
> Kenneth P. Bowman wrote:
>
>> In article <3745B3BB.815FDE87@ssec.wisc.edu>, Paul van Delst
>> <paul.vandelst@ssec.wisc.edu> wrote:
>>
>> As Pavel pointed out in another post, anonymous structures have a "hidden"
>> name that must match in order to be able to concatenate. The trick is to
>> copy your original structure and update the fields, rather than creating a
>> new structure.
>
> Yep I know - I explained this and provided an example in my original post.
>
> I guess what I really trying to say in my long-winded, circuitous way is that
> I do not understand why IDL treats structures differently from any other data
> type. I understand why one would have a restriction on changing the
> definition of the various "tags" within a structure but other than that, why
> should structures or arrays of structures be any different from other
> variable types or arrays? From my point of view, it appears to be an
> implementation issue within IDL - why should I care what the "hidden"
> structure name is? If I cared about structure names I'd used a named
> structure, right?
>
> As Liam Gumley sagely pointed out to me this morning, I am really asking the
> wrong question. Instead of asking "why doesn't this work like I expect it
> should?" the question should be "what do I need to do to get the job done?"

Structures are treated differently because they are different! There
are no straitforward a priori rules which guarantee two structures are
compatible. Contrast this to arrays, for example, where size and type
determine compatibility quite simply.

Internal names are needed because otherwise I'd be able to do:

IDL> a=[{foo:5},{foo:'a'}]

... unless, of course, IDL was willing to traverse each structure in
full and check all tag/type pairs to ensure a match, which seems to be
what you're proposing. This is very different from the simple type
checking done for all the other variable types. And then what happens
if I say:

IDL> a={foo:{foo:1}}

Which is correct? The outer or the inner, or both? Or suppose I'd
really like to do:

IDL> a={foo:1} & b={foo:'testing'}

This simple functionality permitted by anonymous structures would not be
allowed.

Basically, what you're advocating is that *all* structures be named
structures, where the "name" is not specified by the user, but instead
based upon the tag names plus the full recursive type info, to be
gathered either at the time of creation (full-fledged named structs), or
each time a concatenation is performed (special case named structs).
This is not impossible. Presumably it could be done with a suitably
chosen hash function. However, it eliminates the benefits of anonymous
structures, and makes structure concatenation stricter and slower.

My suggestion is to bite the bullet and use a named struct, or stick to
your relaxed assignment.

JD


--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: List yourself in SStreams�
Next Topic: Including files/eps into PS

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

Current Time: Thu Oct 09 22:24:12 PDT 2025

Total time taken to generate the page: 2.23914 seconds