Deterministic Proposal

Guy Ellis wildfiction at
Wed Jun 21 23:24:01 UTC 2017

My thoughts are along the lines that the developer would decide what a
deterministic function was and decorate/tag it as such. That's why I used
the word deterministic and not pure. Basically the developer is signaling
the compiler that given an identical parameter signature the result
received back from the first call can be used for all subsequent results.

The developer implementing compiler optimization would then have a flag
available against any method that would signal if it is deterministic or
not and would decide to use that information or not.

The question is: Would that extra information provide the Compiler
Optimizing Developer with information that they could use to improve
performance or anything else? If you are/were such a
Compiler-Optimizing-Developer how would you use this information?

On Wed, Jun 21, 2017 at 9:59 AM Andreas Rossberg <rossberg at>

> On 21 June 2017 at 18:40, Bradley Meck <bradley.meck at> wrote:
>> You probably mean "pure", not "deterministic", which has nothing to do
>>> with this. However, JavaScript is far, far too impure for any such
>>> annotation to ever make sense or enable any sort of memoization. Consider
>>> let i = 0
>>> let o = {valueOf() {return i++}}
>>> sum(o, 0)
>>> sum(o, 0)
>> If type coercion was disabled within "pure" functions I am not sure this
>> would be a problem.
> A new language mode with modified semantics is a whole new dimension that
> is far from simple to add to JS. And even then the pure subset of JS would
> remain tiny.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list