Use of redundant var

Jon Zeppieri jaz at bu.edu
Sat Aug 23 08:03:19 PDT 2008


On Sat, Aug 23, 2008 at 9:25 AM, Fergus Cooney <f.cooney at gmx.co.uk> wrote:

> I'm also in favour of multiple, "redundant" vars. I use them semantically
> and as a discipline.
>
>    if (something)
>        {
>        var x = 1;
>        :  :  :
>        }
>    else
>        {
>        var x = 2;
>        :  :  :
>        }
>
> When I write the above pattern you won't see x being used outside those
> inner blocks. The two vars are my way of saying that they are independant
> 'x's, although the same name would be being used because they have the same
> meaning.

Okay, but this suggests that if you had 'let' you wouldn't use
redundant declarations.

Or, to put it another way, you only use redundant declarations because
the language lacks block scoping.  I don't think this makes you a
champion of redundant declarations.

-Jon


More information about the Es-discuss mailing list