D to Javascript converter (a hacked up dmd)

Jacob Carlborg doob at me.com
Sat Mar 3 10:07:10 PST 2012


On 2012-03-03 17:29, Adam D. Ruppe wrote:
> 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.

Ok, I see.

> 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.

Well, functions are different.

> 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.


-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list