I am officially requesting Moduled Exports in the likeness of Node.js: https://nodejs.org/api/modules.html
It would be nice to be able to use external functions without following the naming convention the function creator chose.
Psuedocode:
Code: Select all
Class exampleClass{
__New() {
}
exampleMethod(parameter) {
;do something
}
Export(exampleClass)
Code: Select all
exampleFunction(parameter1, parameter2) {
;do something
}
Export(exampleFunction)
Code: Select all
Import(module.ahk)
myclassinstance := new exampleClass()
mynamedfunction := Import(function.ahk)
mynamedfunction("foo","bar")
As a note, its easy in javascript as everything including functions can be saved as objects and transported elsewhere:
Code: Select all
function myCoolFunction() {
// do something
}
module.exports = {
myCoolFunction: myCoolFunction
};
Code: Select all
var myCoolFunctionInstance = require('myCoolFunction');
// searches recursively in parent directory for myCoolFunction library and imports as user specified object.
myCoolFunctionInstance.doSomething()
In addition: I have been working around the outdated way AHK sources code from other files, but increasingly I am coming up against an issue where the same function cannot be defined twice:
This turns into an issue when for example two libraries share a dependency on a third library. In the theoretic circumstance where all libraries are updated and not conflicting, you still have not solved for situations where a library requires an older version of a library (difference in argument order, accepted types, etc)Known limitation: Currently, the name of each subroutine (label) must be unique among those of the entire script. The program will notify you upon launch if there are duplicate labels.
Notes and links:
https://autohotkey.com/docs/Functions.htm#lib