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

Re: Would you consider this a bug?

In article <m2r9wnpdg9.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>,
  David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> wrote:
> muswick@uhrad.com writes:
> > Actually I don't think it is a bug.  One needs to carefully review
> > how IDL handles arrays and indices.
> An artifact not mentioned in the language description is a bug.
> Imagining how this bug might come about does not make it go away.
> > If we go back to the original posted question:
> >
> > > a = [3,4,5]
> > > a[[2,1,0]] = a
> >
> > > a will be set to [3,4,3]
> >
> > Which is correct, based on 'a' being overwritten.  This is avoid huge memory
> > overhead in many cases where the right side equation is complex.
> It is a reasonable optimization in general, but an optimization that
> changes the results of the command is a bug.  Being able to understand
> how this bug comes about does not make it "correct".  IDL needs to
> find out where this optimization is inappropriate and not do it where
> harm does ensue.
> You cannot define correctness of a program based on the artifacts of
> some optimizer.  An optimizer has to work behind the scenes.

I think you missed my point.  Your usage is incorrect, not the optimizer.
If the syntax of a language is to optimize 'a' and not optimize 'a[*]' than
any other assumption is incorrect usage and therefore "Not a bug".

I was slightly wrong in how I described the optimization.  One of the big
problems in IDL is the high memory overhead when working with the same array.
I want to be able to turn off making a copy of the array everytime I do an
operation where the result goes into itself.

Yes, Temporary() can be used, but how does one in IDL properly do the
following computation without getting a high memory overhead:

a = a + a*a

Do I write:   a = TEMPORARY(a + a*a)   or
       a = TEMPORARY(a) + TEMPORARY(a*a)   or

In using IDL for medical image processing where I might use 512x512x256
element arrays,  making multiple copies can cause a multitude of memory

I give the designers of IDL pretty good marks in making comprimises where
needed without making IDL hard to use.

You are correct, that the problem as described is a bug if 'a[[2,1,0]] = a'
is suppose to make a copy of 'a' first.  My original post was to indicate
that the IDL manuals never make that statement, and where ever a left side
elements are explicitly specified, the right side elements are also
explicitly specified.

Thus the results of your original post is correct - not a bug, since the
inferred intent was to overwrite the 'a' array in the order specified by the
internal array numbers: '[2,1,0]'.  If your desire is to make a temporary
copy first, use 'a[*]'.

As another poster pointed out, the left side usage of explicit element
description, while allowed, and has merits (just like the infamous GOTO),
usage should be discouraged because of the ambiquities it can present.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own