Deterministic Proposal
Andreas Rossberg
rossberg at google.com
Thu Jun 22 07:14:29 UTC 2017
On 22 June 2017 at 01:24, Guy Ellis <wildfiction at gmail.com> wrote:
> 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.
>
Except in a very small set of uninteresting cases, such an optimisation is
not allowed, because it changes the semantics of the function. A "tag" as a
compiler hint would not change that. The semantics of every language
construct has to be well-defined, and must not depend on whether or not a
compiler chooses to apply certain optimisations.
> 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 google.com>
> wrote:
>
>> On 21 June 2017 at 18:40, Bradley Meck <bradley.meck at gmail.com> 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.
>>
>
> _______________________________________________
> 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/20170622/e9f322b8/attachment.html>
More information about the es-discuss
mailing list