Should SORT(Undefined) give an error message? [message #93037] |
Wed, 13 April 2016 10:28  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Currently one can SORT() an undefined variable without getting an error message
IDL> sort(undefined)
0
Certainly, the current result is inconsistent with the documentation:
"The result is always a vector of integer type with the same number of elements as Array." since in this case Array has 0 elements.
I think one should get an error message the same way one does with sqrt(undefined) or max(undefined)
In my case, the current behavior slowed down my debugging because I was using the sort index of Vector A to sort another vector B. Vector A was mistakenly undefined but Vector B was valid. Therefore, B[SORT(A)] was also valid, and the program happily proceeded. --Wayne
|
|
|
Re: Should SORT(Undefined) give an error message? [message #93038 is a reply to message #93037] |
Wed, 13 April 2016 14:03  |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Wednesday, April 13, 2016 at 7:28:13 PM UTC+2, wlandsman wrote:
> Currently one can SORT() an undefined variable without getting an error message
>
> IDL> sort(undefined)
> 0
>
> Certainly, the current result is inconsistent with the documentation:
>
> "The result is always a vector of integer type with the same number of elements as Array." since in this case Array has 0 elements.
>
>
> I think one should get an error message the same way one does with sqrt(undefined) or max(undefined)
>
> In my case, the current behavior slowed down my debugging because I was using the sort index of Vector A to sort another vector B. Vector A was mistakenly undefined but Vector B was valid. Therefore, B[SORT(A)] was also valid, and the program happily proceeded. --Wayne
I think it's a bug. It gives an error message in GDL or FL.
regards,
Lajos
|
|
|