shortcuts for defining block-local private names, plays nicely with @foo syntax

Gavin Barraclough barraclough at
Mon Jan 23 12:54:28 PST 2012

On Jan 23, 2012, at 12:27 PM, Brendan Eich wrote:
> No, the private binding form that is desugared from
>  private foo;
> to
>  const foo = Name.create("foo");
> or better (with hygiene to use the right Name, etc.) is lexical in its binding structure.

Is the intention here that the private name object would be in scope, and accessible to the user? – if so, this does seem useful, but using the plain name of the property seems potentially prone to typos, e.g.

let o = {};
	private x:
	o.setX = function(x) {
		@x = x;
	o.getX = function() {
		return x; // should be 'return @x;'

I seems that this would be an easy mistake to make, and doesn't appear to be a syntax error is x is in scope.  Wanting to pass around the private name seems like a less common use case, so perhaps it might be worth making it slightly harder to get to the private name?, e.g.

const @@foo = Name.create("foo");
const @{foo} = Name.create("foo");
const @"foo" = Name.create("foo");

function getPrivateName() { return @@foo; }
function getPrivateName() { return @{foo}; }
function getPrivateName() { return @"foo"; }


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

More information about the es-discuss mailing list