Conversion – Functions
While providing functionality similar capabilities for functions calls and dynamic parameter lists, the IDL and Python implementation patterns are quite different. IDL provides a “functional” based approach, tuned to the needs of the interactive user and based on it’s FORTRAN roots. On the other hand, Pythons implementation is based on modern methodologies, based on common vararg patterns and leveraging it’s built in data structures.
The major functional arguments differences between IDL and Python include:
- Python only supports functions and not subroutines.
- IDL uses functions and special keyword names to manage dynamic parameter lists, while Python uses standard list data types.
- No partial keyword expansion capability in Python – full keyword symbols are required when making routine calls.
- Input parameters and keywords are passed by value, meaning output values are not supported by function parameters. Output values are only supported as the return value from a Python function. Unlike IDL, Python functions can return more than one value though.
- In Python, undefined variables in a function call is an error. In IDL, the use of undefined variables is a key implementation pattern.
While the function structure and syntax gaps between IDL and Python are large, Pike addresses each through a straight syntax translation and runtime functionality.