New private names proposal

thaddee yann tyl thaddee.tyl at
Thu Dec 23 12:55:12 PST 2010

One last syntax proposal, since I agree with Brendan Eich about the
Perlishness of the number sign.
"private ::secret;" :

a = {};
k = {a: a};
a['k'] = k;
function aa(o) {
  private ::a;
  k::a = o;  // or: private c.a; c.a = o;
  a.a = a.k.a;  // or: a['a'] = a['k']['a'];
  a.a = k::a;  // here, on the other hand, k.a is the private stuff.
  return ::a;
let a2 = aa(a);
print( a[a2] === a );  // true

We should still be able to use "obj.secret" as a way to access
properties, even in the scope of "private ::secret;",
and the syntax seems vaguely familiar to C++ and Ruby programmers
(Ruby's syntax for symbols uses only ":",
but we can't use it here, to avoid confusion with labels).

From: David-Sarah Hopwood <david-sarah at>
>> I understand that the number sign gets really heavy and annoying after
>> some time. As a result, I suggest a simpler syntax, "private
>> .secret;":
>>   private .a;
>>   k..a = o;
>I find this less readable, and I think it would be easy to miss the
>difference between . and .. in larger expressions. Also, the .. operator
>is used in other languages for ranges.

More information about the es-discuss mailing list