Is it possible, by any means, to do something like this:
function A() {
var Loaded = 'loaded';
raise Loaded;
}
function A_raise(evt) {
console.log(evt);
}
A.prototype.constructor = A;
A.prototype.raise = A_raise;
The critical part being the line:
raise Loaded;
The only way to get a parentheses-less function call in JavaScript is to define a setter/getter property, or to override one of the special methods :
toStringorvalueOf. In neither case do you have really good control over the parameter that gets passed to the call.You can invoke a constructor without parentheses, but again, cannot pass arguments.
One reason you can't is semicolon insertion.
is a function call, as is
and
is a valid conditional because
ifis a core part of the language but if you could just drop the parentheses from a function call then semicolon-insertion would have to treat code likeas a variable initialized to the result of calling a function.
Since you asked about language extensions, Chapter 16 of the EcmaScript specification says that interpreters are allowed to add to the grammar of the language,
so since
is not a valid expression or statement in the language, they could allow it, but they could not do so in a way that changes the meaning of
which must have the same meaning as
so the interpreter would have to make
raisea new restricted production which is problematic because of the verbiage:That is probably meant to be non-normative, but it is not explicitly so.