import/namespace system

Propose new features and changes
User avatar
Posts: 803
Joined: 06 Oct 2015, 21:39

import/namespace system

21 Mar 2018, 19:43

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 :)
User avatar
Posts: 4036
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: import/namespace system

22 Mar 2018, 02:36

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
Recommends AHK Studio

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 6 guests