> At one point I hacked up a version of free variable checker that took
> a list of free variable names instead of (as well as) inspecting the
> global object. Maybe this is worth doing again?
I think it's definitely worth doing. Not that I wasn't before, but this
recent bug fix has left no doubt. It's one less thing to think about,
which leaves more brain cells free for tasks that computers aren't good
at -- writing programs, as opposed to running them.
Oddly enough, I have no use for IDEs. There are certain things you
just have to know cold. Humans are actually good at that, if the
number of things isn't too much. And if they have backup. Because
everyone messes up every once in awhile.
I guess the only question is how we're going to interface with it --
through magic comments, some kind of syntax, or just programmatically
through some sort of plugin or scripting system?
Typescript uses these things called "typings" or definition files.
http://typescript.codeplex.com/SourceControl/changeset/view/ac38ce9e29b3#typings/jquery.d.ts
They also have something called "ambient declarations".
http://www.typescriptlang.org/Content/TypeScript%20Language%20Specification.pdf
declare var document;
document.title = "Hello"; // Ok because document has been declared
I think adding syntax is a little too heavyweight, especially since it's
not even part of the spec.
Magic comments? Maybe. Though that's a slippery slope, and you might end
up with closure-compiler all over again. And I don't think Peter would
approve of that.
I think scripting is probably the easiest, and the most powerful. I
know, with great power comes great... yada yada. Just give me the power
already!
Well, maybe some simple magic comments, as long as we keep it dead
simple. I don't think it's worth trying to declare what members of an
object are valid. Though I guess we could just generate these
complicated magic comments, which wouldn't be that bad.
At that point, maybe just syntax, in a dedicated file that doesn't
participate at all in the compilation at all except during the
checking phase.
Wait. That's 'typings' all over again.
But if you're going to do that, you might as well just use JS
scripting. That way you have a much more expressive language, plus you
don't even have to write or modify the parser.
I'm thinking in addition to a simple list, the ability to pass in a
function that takes the current scope chain and the current var name
being checked as arguments, and returns true if it's "on the list" and
false if it should get back in line and wait for the normal checking
procedure to go through all the vars.
butabi = 42; // what do you mean, I'm not on the list!
https://codereview.appspot.com/7509043/