gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
270 stars 61 forks source link

keyword /nozero in several functions + useless code ! #1818

Open alaingdl opened 2 months ago

alaingdl commented 2 months ago

2 points :

e.g. :

    arr(e, dim);
    if (dim[0] == 0)
      throw GDLException("Array dimensions must be greater than 0");

but in arr()

...
      if (ret < 0) throw GDLException(BadDims);
...
      if (newDim < 1) throw GDLException(BadDims);

Would someone give a look and canfirm we can removed the useless code ?

in fact : no /nozero in STRARR in IDL, and /nozero does exist in IDL for OBJARR & PRTARR but are not documented !

GDL> help,/lib, name='*arr'
Library procedures (0):
Library functions (14):
res=BYTARR([8 Args],NOZERO)
res=COMPLEXARR([8 Args],NOZERO)
res=DBLARR([8 Args],NOZERO)
res=DCOMPLEXARR([8 Args],NOZERO)
res=FLTARR([8 Args],NOZERO)
res=INTARR([8 Args],NOZERO)
res=LON64ARR([8 Args],NOZERO)
res=LONARR([8 Args],NOZERO)
res=OBJARR([8 Args])                                      <<---- missing in GDL
res=PTRARR([8 Args],ALLOCATE_HEAP)      <<---- missing in GDL
res=STRARR([8 Args],NOZERO)                    <<---- to be removed in GDL 
res=UINTARR([8 Args],NOZERO)
res=ULON64ARR([8 Args],NOZERO)
res=ULONARR([8 Args],NOZERO)
% At $MAIN$          
GillesDuvert commented 2 months ago

indeed arr() checks dims are not zero. So the supplementary test is not useful. Same as some checks on number of params when e->NParam(n) has been called before. Not an issue, though.