In some languages its possible to write two versions of the same function which take in differing arguments:
add(int, int)
add(float, float)
add(string, string)
in gamemaker this is not really a thing, however with a sufficiently advanced type handler and post processer it would be possible to restructure a function based on information like this:
function add(_arg0, _arg1) {
if (is_string(_arg0) && is_string(_arg1)) {
_arg0 = real(_arg0);
_arg1 = real(_arg1);
}
return _arg0 + _arg1;
}
Which internally could be expanded into 2 separate functions:
__gmlc_add_string_string
__gmlc_add_real_real
This of course is just an example, however when ever it comes to multi type functions this become more useful when its not a small branching statement, but instead a diverse branching execution. While this is helpful to test the limitations of compile time type depiction, its a lot of work, and prior to working on this a catalog of every single multi type function should actually be parsed, and sorted to see which functions this would actually make a substantial impact on, and how much of an impact those would make, as in cross referencing to real world code (all gml libraries on github) and seeing how often those functions are even used. It may be possible that the only times this would reasonably be useful is for only like 20 functions which hardly ever get used.
In some languages its possible to write two versions of the same function which take in differing arguments:
in gamemaker this is not really a thing, however with a sufficiently advanced type handler and post processer it would be possible to restructure a function based on information like this:
Which internally could be expanded into 2 separate functions:
This of course is just an example, however when ever it comes to multi type functions this become more useful when its not a small branching statement, but instead a diverse branching execution. While this is helpful to test the limitations of compile time type depiction, its a lot of work, and prior to working on this a catalog of every single multi type function should actually be parsed, and sorted to see which functions this would actually make a substantial impact on, and how much of an impact those would make, as in cross referencing to real world code (all gml libraries on github) and seeing how often those functions are even used. It may be possible that the only times this would reasonably be useful is for only like 20 functions which hardly ever get used.