Page 1 of 1

import/namespace system

Posted: 21 Mar 2018, 19:43
by kczx3
I had the idea that AHK might benefit from a bit more robust #Include system than what it currently does.

While I really do enjoy the import/export system of JavaScript, I think that would be quite overkill, at least to start.

My proposal would be to add a new # directive that would be used the file to be included. I imagine this being used mostly for all of the various function libraries out there that are typically included. My suggestion would be to use something like #Using <namespace> or #namespace <namespace>. When that file is included, all of its variables/functions/classes would be found under that single namespace. I suppose an alternative would be to simply wrap all of the variables/functions/classes into a class and use them all as static definitions.

Maybe its not a good idea. Just thought it might help with the issue of global namespace pollution... and with people prefixing their functions with weird things like initials and etc.

Beyond that, using an import system like JavaScript or Python would be neat to only import what you need. I can be optimistic :)

Re: import/namespace system

Posted: 22 Mar 2018, 02:36
by nnnik
I prefer if namespace is defined by the file that includes.
And that you can't make changes to it.
E.g. include gdip.ahk >> everything is in gdip.whatever
Btw this suggestion has been made a few dozen times