Has there been any work done on pure functions in EcmaScript? The way I
imagine it, there would be a way to indicate that a function should be pure
(by using a symbol or a new keyword, although I understand new keywords
aren't terribly popular). The pure function is not allowed to access any
variable outside its own scope. Any access to a variable outside the scope
of the function would result in a Reference Error, with an indication that
the reference attempt was made from a pure function. This also applies to
any function called from within the pure function. The entire stack of a
pure function must be pure. This also means the pure function cannot access
the [this] object. Only the parameters passed to the function can be used
in the calculation.
The syntax could be something like this (the @ indicates that it is pure):
function sum@(a, b){
return a+b;
}
var sum = function@(a, b){
return a+b;
}
Marius Gundersen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss