To be honest it's probably solvable using decorators with memoization.

If we ever have a decorators (any updates on proposal BTW?) language can
have decorators with implementation-specific behaviour (eg. "functions
decorated with @pure builtin decorator can be assumed by engine to not
produce side effects and became a subject of lazy evaluation" or
"@memorySizeCache(size) builtin decorator has semantics almost identical to
builtin @cache decotor, but engine can drop entries in cache if it exceeds
given treshold "). Fallback for other implementations would be of course
no-op.



On Wed, Jun 21, 2017 at 5:34 PM, Isiah Meadows <isiahmead...@gmail.com>
wrote:

> I'd like to note that even Haskell compilers (which can check for this
> trivially) never memoize implicitly. They only memoize infinite data
> structures.
>
> As for this proposal, I see exactly zero benefit whatsoever. Engines
> already cover the relevant optimization opportunity without this
> (through type ICs), and it's often faster in practice to recalculate
> than memoize based on argument.
>
> The only time I have found memoization to be very useful is in one
> specific case: lazy evaluation (run once). But that is constrained to
> just evaluating a thunk and storing the result.
> -----
>
> Isiah Meadows
> m...@isiahmeadows.com
>
> Looking for web consulting? Or a new website?
> Send me an email and we can get started.
> www.isiahmeadows.com
>
>
> On Wed, Jun 21, 2017 at 6:01 AM, Jussi Kalliokoski
> <jussi.kallioko...@gmail.com> wrote:
> >
> >> deterministic function sum(a, b) { return a + b; }
> >
> >
> > Ironically, having the engine decide when to memoize would make the
> > "deterministic" functions non-deterministic:
> >
> > deterministic function foo(a, b) { return { a, b }; }
> > foo(1, 2) === foo(1, 2) // may or may not be true
> >
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss@mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to