Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#585 using list as a variable leads to problems

v1.0 (example)
closed-wont-fix
nobody
None
5
2014-07-13
2014-01-20
Martin Svec
No

This gives me problems:

This one took me a while to figure out:
It seems using a variable named "list" as an array is generally not a good idea. It seems to somehow conflict with the list function.

Example:

IDL 7.0
IDL> list=-1
IDL> print,list(0)
-1

GDL> list=-1
GDL> print,list(0)
0

Discussion

  • Marc Schellens
    Marc Schellens
    2014-03-22

    • status: open --> closed-fixed
     
  • Marc Schellens
    Marc Schellens
    2014-03-27

    • status: closed-fixed --> closed-wont-fix
     
  • Marc Schellens
    Marc Schellens
    2014-03-27

    IDL behaves far from graceful (one could almost say: it behaves evil) here:

    IDL 8.0
    IDL> print,list(0)
    0
    IDL> list=1
    IDL> print,list(0)
    0
    But:
    IDL> list=1
    IDL> print,list(0)
    1

    This means: IDL will execute a program differently, depending on someone called LIST(0) before or not!!! So imagine one works at the IDL command line and does "l=list(0)" and then runs his program. Probably it will crash. He restarts the session, runs the program again and voila, all fine. But next time, who knows...

    BTW: It does not make things better that:
    IDL> sin=1
    IDL> print,sin(0)
    0.00000

    As GDL is consistent, I think GDL's behaviour is MUCH better than IDL's.

     
  • Alain C.
    Alain C.
    2014-03-27

    And also the results in IDL are different between IDL 7.x and IDL >= 8.0:
    LIST() appeared in IDL 8.0

    Alain