On Saturday, 3 March 2012 at 12:12:53 UTC, Jacob Carlborg wrote:
Wouldn't you save a lot of characters by properly scoping the variables instead of using unique names?

There's no such thing as proper scoping in Javascript.

The next best thing is the nested functions, but that's
really just trading one poison for another.


D mangled names do a lot more than scoping, too, anyway.
Mangled names overload properly:

void a(int, int);
void a(int, string);

a(1, "one"); // which one gets called?


With dmd's name mangling, it Just Works.


Now, there might be something to gain by using prettier
local variable names, but it is a lot of extra work and
IMO the benefit is still very small.


Note that local variables are still local variables
95% of the time (and the other 5% is a bug that I'm
hoping to fix today), so its already scoped almost
as well as it can be on the function level.



The biggest benefit is readability and size. Size is handled
by running it through a string replacer (tools/mangledown.d).

Readability is a nice gain, but not an essential one I think;
it is readable right now if you want to.

Reply via email to