2665 Rate this article:
No rating

What The *Bleep* is IDL Doing: Obsolete Routines

Dain Cilke

Obsolete – No longer produced or used; out of date.

One of the questions developers have to answer when implementing new functionality is whether it can be logically added to an existing routine. Grouping functionality into a single routine allows for a less cluttered API and takes advantage of the dynamically typed nature of IDL. However, two considerations need to be made before adding new functionality to an existing routine. First, does it make sense? While it is a good practice to group similar or complementing functionality, adding functionality to an existing routine for the sake of adding functionality is likely to cause more headaches then necessary. A good rule to follow is if the new functionality is implemented in its own code path, it should be put in a new routine. Second, does the new functionality alter the behavior of the existing routine? Developers rely on routines to return consistent results. If the behavior of a routine suddenly changed, it would cause numerous headaches as code would constantly be rewritten and one would never be able to trust old code. Therefore, if the new functionality needs to be incorporated in an existing routine, but by doing so would cause the behavior of the existing routine to change, the old routine should be obsoleted and a new routine should written to replace it, encompassing the old and new functionality. An example of this is the obsoleted routine FINDFILE. For those who are unfamiliar with FINDFILE, it was IDL’s solution to searching for files on a given file system which was replaced with FILE_SEARCH in IDL 5.5. One of the major limitations of FINDFILE was its reliance on the underlying system to search for files. For example:

  • Under Macintosh, FINDFILE function brackets the returned filename in colons if the file is a folder (e.g., :lib:)
  • Under UNIX, to refer to all of the files in a directory only, use FINDFILE('/ File_Specification /*.*'). To include all the files in any subdirectories, use FINDFILE('/ File_Specification /*')
  • Under VMS, FINDFILE returns the full path specification for any file it finds.
  • Under Windows, FINDFILE appends a "\" character to the end of the returned file name if the file is a directory. To refer to all the files in a specific directory only, use FINDFILE('\ File_Specification \*').

When it came to adding file introspection to IDL, it made sense to add the functionality to FINDFILE. Not only would it help with finding files (i.e. searching for only directories or searching for files which you have read access to but it would also make FINDFILE the one stop shop for querying information about the file system. However, there was a problem. Since FINDFILE was so platform dependent, the new functionality required a complete rework to remove its dependencies which resulted in a change in the behavior of FINDFILE (since FINDFILE was released, any change to the output would break backwards compatibility). Since it was already determined the new functionality should be bundled with the old functionality, FINDFILE was obsoleted and FILE_SEARCH was introduced as its replacement.

Please login or register to post comments.