> > >> I don't understand this claim, any legal AssignmentExpression form is >> allowed. >> >> >>> I've said this before, but without the equals it looks too much like a >>> declaration: >>> >>> export default class C {} >>> var c = new C(); // No C defined, WTF? >>> >> >> Why is this surprising? >> > > It is surprising because it looks like it should work like > export class C {} > The keyword 'default' looks like a modifier like 'const'. >
I completely agree with this. It looks like a modifier. In addition to not having an = or some other reason to think it will be evaluated as an expression, "default" *is* a reserved word *and* has special significance here. Yes, it is grammatically unambiguous and can be learned, but this is a question of intuition. The meaning here goes very strongly against my intuition. > > > >> >> If a developer knows how named function expression bindings work today, >> this won't be a big surprise. >> > > I know how named function expressions work and it's still surprising. > Same here. If anything, I would say that it makes more sense to go ahead and run with the intuition we seem to be feeling with is that it seems like a modifier of the export. So maybe like: export default class C {} var c = new C(); //works export default function f(){} f(); //works export default let obj = {a:1,b:2}; var a = obj.a; //works
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss