IDL favors simple names, and it blurs the user level distinction between system routines and user routines. See Managing IDL Paths for more on how IDL finds routine names on its path.

Names should make sense, be easy to remember, and not require too much typing. Language transparency also results in very human-readable code. In conjunction with the way IDL searches for routines, this may cause either user level or system level conflicts.

User Level Conflicts

In the user level case, an IDL user writes a routine that is not part of the base release of IDL, and places it in a local library. At some later date, a new version of IDL is installed that contains a new IDL library routine with the same name as the user's routine. Depending on the order of the directories in the user’s path, one of these two routines is executed. If the user’s routine is used, IDL library code that calls the routine will get the wrong version and fail in strange and mysterious ways. If the IDL routine is used, the IDL library will be satisfied, but the user's library will get the wrong version, also with bad results.

System Level Conflicts

The system level case is similar, but harder to work around. In this case, the user creates a local routine as before, but the new version of IDL contains a system routine with the same name. In this case, IDL will always choose to use the system routine, and the user routine vanishes from view. The order of the search path is meaningless in this case because the search path is not even consulted. A system routine always has precedence over a user routine.

The Workbench Recognizes Duplicate Routine Names

The IDL Workbench now automatically checks for duplicate routine names and displays a warning icon at the relevant code line, and in the Problems View. There is also a preference setting that allows you to control this behavior.

Choosing Routine Names to Avoid Conflicts


We recommend devising a routine naming strategy to avoid naming conflicts. The core idea of this convention (described in detail in Advice for Library Authors) is to prefix all library routine names with a unique identifier, one indicative of your organization or project. We reserve routine names that are generic, and those with an “IDL” prefix on behalf of the entire IDL community. Prefixing your user library routines significantly reduces the risk of namespace collisions with IDL routines.

As a library author, your decision to follow a routine prefixing strategy benefits the entire IDL community. This convention translates into simplicity and reliability, allowing IDL system routines to always take precedence over user routines. It also raises the visibility of your routines, readily distinguishing them as part of your library.

Note: For instructions on how to prefix an existing user library, see Converting Existing Libraries.

Cross-Platform Naming of IDL .pro Files


When naming IDL .pro files used in cross-platform applications, you need to know the various platforms’ file naming conventions and limitations. For example, the “:” character is not allowed in a filename under Microsoft Windows.

Be careful with case when naming files. For example, while Microsoft Windows systems present file names using mixed case, file names are in fact case-insensitive. Under Unix, file names are case sensitive—file.pro is different from File.pro.

When writing cross-platform applications, avoid using filenames that are different only in case. The safest course is to use filenames that are all lower case.

Remember, too, that IDL commands are themselves case-insensitive. If entered at the IDL command prompt, the following are equivalent:

IDL> command
IDL> COMMAND
IDL> CommanD

Automatic Compilation and Case Sensitivity

On UNIX platforms, where filename case matters, IDL looks for a lower-case filename when you enter the name of a user-written routine at the IDL command prompt. Thus, if you save your program file as myprogram.pro and enter the following at the IDL command prompt:

IDL> MyProgram

IDL will compile the file myprogram.pro and attempt to execute a procedure named myprogram.

If you save your program file as MyProgram.pro and enter the following at the IDL command prompt:

IDL> MyProgram

IDL will not compile the file MyProgram.pro and will issue an error that looks like:

% Attempt to call undefined procedure/function: 'MYPROGRAM'.
% Execution halted at: $MAIN$

You can compile and run a program with a mixed- or upper-case file name on a UNIX platform by using IDL’s .COMPILE or .RUN executive commands:

IDL> .COMPILE MyProgram
IDL> MyProgram

or, if MyProgram.pro contains a main-level program:

IDL> .RUN MyProgram

In general we recommend that you use lower-case file names on platforms where case matters.