Exo
Exo copied to clipboard
Clearing up the global scope
I think rather than messing up the global scope, it'd be a better idea to introduce an process
object like nodejs does.
process.argv
can contain all the arguments.
process.env
can contain the environment variables.
You're talking only about the "Parameters" variable? (the equivalent of "1", "2", in AHK). Seeing as how the global scope is already polluted by 465 keywords, 1 extra isn't a big deal.
However, your idea is worth investigating if we want to enrich "Parameters" (or another name equivalent to the Node.js "Process") with other properties. But most of the items here (http://nodejs.org/api/process.html) are served by other AHK functions. E.g: process.cwd() --> A_WorkingDir / A_ScriptDir process.exit() --> ExitApp() etc.
P.S. Initially, I've though about enclosing ALL functions in an "Exo" scope, but then the readability would have suffered.
Yes, it would be cool for it to be all contained. :+1:
Adding Parameters
alone can hardly be considered "messing up the global scope". If anything, it's tidier than how AutoHotkey v1 does it (but v2 uses Args
). I would assume menixator was talking about the library in general.
Parameters aside, usage being almost identical to AutoHotkey is of great benefit. AutoHotkey's large number of "global" names (built-in variables, functions and commands) has never been a problem to me, so I don't see why it would be with Exo. Although with JavaScript, functions can be confused with variables (e.g. best not to use Control
as a variable name), this is mitigated by JavaScript's case-sensitivity (control
is okay).
I agree with both viewpoints. I insist on having the current implementation because easy migration is a big deal. But I hate not having the option to clean up the global scope when an exception arises. That's why I'm planning on using custom comments:
/* #GlobalScope false */
The above directive would default to true
, which means we pollute the window scope.
Otherwise, we use the Exo
scope, e.g. alert(Exo.A_Now)