New private names proposal

Chuck Jazdzewski chuckj at
Thu Dec 16 14:40:28 PST 2010

Ø  Currently is JS, x['foo'] and are precisely identical in all contexts.

This is true when the string contains a is a legal identifier and false otherwise. The [] syntax is a superset of the '.' syntax. The proposal preserves this through the use of "#" expression, e.g.,

                private x;
                this.x = 1;

is equivalent to

                private x;
                this[#.x] = 1;

which means it is still regular. What it doesn't preserve is the property name is always representable as a string. The property name becomes a plus type of String+Name. With proxies it becomes a String+Name+ProxiedName type where the ProxiedName is used to hide the Name value.


From: es-discuss-bounces at [mailto:es-discuss-bounces at] On Behalf Of Mark S. Miller
Sent: Thursday, December 16, 2010 2:19 PM
To: Kris Kowal
Cc: es-discuss at
Subject: Re: New private names proposal

On Thu, Dec 16, 2010 at 1:58 PM, Kris Kowal <kris.kowal at<mailto:kris.kowal at>> wrote:
On Thu, Dec 16, 2010 at 1:53 PM, David Herman <dherman at<mailto:dherman at>> wrote:
>    function Point(x, y) {
>        private x, y;
>        this.x = x;
>        this.y = y;
>        ...
>    }
> than
>    function Point(x, y) {
>        var _x = gensym(), _y = gensym();
>        this[_x] = x;
>        this[_y] = y;
>    }
I tend to disagree with most developers, so take it with a grain of
salt that I find the latter form, with all the implied abilities,
easier to understand.

I do too. While terseness clearly contributes to understandability, regularity and simplicity do too. When these conflict, we should be very careful about sacrificing regularity.

Currently is JS, x['foo'] and are precisely identical in all contexts. This regularity helps understandability. The terseness difference above is not an adequate reason to sacrifice it.

Kris Kowal
es-discuss mailing list
es-discuss at<mailto:es-discuss at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list