Resived October 2021; see History
DEFALIAS <routine-alias>() = <real-routine>()
DEFALIAS (define alias) allows aliases to be defined for the names of functions and procedures.
This can be a useful code management technique for isolating lower level changes or variations in routines—due to differences in versions, implementation, etc.—from the higher level application. For example, an application may have many different discount calculation routines based on the type of discount, some of which might be effectively the same. Rather than forcing the higher level code to know which discounts are effectively the same, or forcing you to maintain redundant routines which differ only by name, you can use DEFALIAS to create aliases. For example, the following statement would cause any subsequent references to the function Fn'Senior'Discount(qty,gender) to be converted into references to the function Fn'AARP'Discount(qty,gender):
DEFALIAS Fn'Senior'Discount() = Fn'AARP'Discount()
Notes
• | Currently this applies only to functions and procedures and not subroutines |
• | The empty set of parentheses is mandatory for both the alias and the real routine name. Currently the alias only affects the name; the arguments are passed through without change. |
• | This is purely a compiler-level mechanism and does not require any runtime support—i.e. it is backward compatible to all runtimes. |
See Also
History
2021 October, A-Shell 6.5.1708, compiler edit 957: DEFALIAS now updates the effective type (string or numeric) of the function, making it possible to alias a numeric function call to a string function or vice versa, e.g.: DEFALIAS Fn'Foo() = Fn'Foo$() and DEFALIAS Fn'Bar$() = Fn'Bar()
2017 November, A-Shell 6.5.1620, Compiler edit 838: Statement added to A-Shell