On 8 October 2012 19:18, Allen Wirfs-Brock <[email protected]> wrote:
>
> On Oct 8, 2012, at 10:04 AM, Andreas Rossberg wrote:
>
>> On 8 October 2012 18:24, Allen Wirfs-Brock <[email protected]> wrote:
>>> You desugaring would break ES<=5.1 compatibility for:
>>>
>>> (function (p) {
>>> var p;
>>> return typeof p
>>> })("test")
>>>
>>> ES5.1 returns "string", your desugaring returns "undefined"
>>
>> I'm probably just being blind, but I'm not seeing it. Why?
>>
> In ES <= 5.1, function declarations over-write formal parameters. But var
> declarations, without initializer do not assign undefined to already local
> bindings (including formal parameters) that already exist.
Yes.
> You desugaring would create a new var declaration in a new scope contours
> that would be initialized to undefined and shadow the like-named formal
> parameter.
But it creates no new var declarations. Your function would presumably become
function(p) {
return (function(p) {
var p;
return typeof p;
})(p)
}
That is, the desugaring degenerates into a simple (and redundant)
eta-expansion in all cases where no actual defaults occur. As far as I
can see that shouldn't change the meaning of any local var
declarations.
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss