[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays in structures; workarounds?




"J.D. Smith" <jdsmith@astro.cornell.edu> writes:

> The problem here is reliance on *trailing* shallow dimensions.  The
> IDL manual quotes us:
> 
> "As with other subscript operations, trailing degenerate dimensions
> (those with a size of 1) are eliminated."
> 
> While I can't agree with IDL's mixed notion of a variable's dimensionality
> between help and direct structure member access, I think IDL has always been
> clear about this point.

Yes, this aspect of IDL's behavior is documented.  I've complained
about this before because the policy has the habit of biting you at
very awkward moments.  As a programmer, you rarely expect the shapes
of your arrays to change without your asking!

But my point here was that there is absolutely *no* legitimate way to
find the true dimensions of a structure tag.  Hopefully you will see
why I want this soon enough, when I have time to finish my little
project.  It's pretty cool.

> The one place you are justified in complaining is the truncation of a single
> element vector to a scalar: this is a bug (or at least an inconsistency), and
> affects structure field access only:

Bingo.  IDL's behavior of trimming degnerate dimensions from variables
is *usually* okay because it still leaves you with an array at the
end.  However, when single-element tags in structures are extracted
they are (a) converted to scalars, and (b) there is no way to know
that this happened.  Try passing this as X or Y to a routine like PLOT
and you get a crashola.  Documented or not, this is ridiculous
behavior.

Multi-element arrays have a similar problem, but I posted a solution
for that.  I was hoping to close this final gap...

Oh well,
Craig

P.S.  I should be writing a proposal now.  Yikes.  Back to work..
-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------