Pure functions in EcmaScript

David Bruant bruant.d at gmail.com
Wed Nov 28 04:21:34 PST 2012


Hi Marius,

I won't say the idea is bad, but what would be the benefit of this new 
type of function?

 From experience on this list, if a new idea cannot prove to make a 
major difference with what currently exists, it is not considered to be 
added to the ES6 spec.
The major difference can be in performance, security, language 
extensibility, programming idioms/conveniences, etc.
Do you have reasons to think pure functions as you propose them make 
that big of an improvement as opposed to JS as it is?

David

Le 28/11/2012 12:50, Marius Gundersen a écrit :
> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121128/772f61d5/attachment.html>


More information about the es-discuss mailing list