Methods and shared functions have a common requirement that all declarations of a given name have the same signature. The reason for this is for the compiler to know the expected parameters and return type when parsing calls to them. This is useful not only so that the compiler can report errors at compile time, but also so it can setup any necessary type conversion operations. This requirement is so important to the success of the system, that the compiler enforces it by rejecting attempts to compile methods or shared functions that don't conform to the expected signature.
This system works well, until it is desired to change the signature of a function or method. Then a problem results, because since the code probably exists in more than one script, none of the signatures can be changed, because the compiler will return an error.
Fixing this situation requires utilizing one of the methods described below.
Note: It is important to recompile all scripts that call a function/method, after changing its signature, since any type conversions for the parameters and return value may be different. This is true not just for methods and shared functions, but for public and external functions as well.
Ways to change a signature
- Clearing the signature
Changing a signature by renaming
Often when you are modifying a signature to introduce new parameters, choosing a new name is appropriate to more accurately describe what the method or function does. In this case, you have the option of creating a new function or method with the proper signature, and leaving the old one for backwards compatibility (if appropriate).
If the new functionality requires an extra parameter (as opposed to a parameter that is not required), then it may be desirable to rename the existing method instead of leaving the old one in place. This ensures that errors will be properly generated when compiling new scripts, and/or in running code that has not yet been fixed for the new signature.
Clearing the signature
The Script Editor supports a method of clearing a signature, so that a new one can be made by compiling a script with the new signature. You may utilize this feature by
double-clicking the error that appears in the script editor when you attempt to compile your script with the new method signature.
Once the signature has been cleared, you may submit a new signature by compiling and submitting the script that contains the new signature.
Remember, if you change a signature, you must also update all of the scripts that implement that method or function.
You must also update all of the scripts which make calls to that method or function, to update the signatures there as well.