Deterministic Proposal
kdex
kdex at kdex.de
Tue Jun 20 23:10:40 UTC 2017
Also, "compiler memoization" may not necessarily be as useful as one might
think. It's a good thing to keep memoization abstract/parameterized, so if
anything, it should be defined via a (standard) library as a function, not via
syntax.
Think of it like this: It might be enough for your application only to memoize
the last `n` results. If you don't, depending on your function, you might be
blowing up memory rather quickly.
On Wednesday, June 21, 2017 1:03:20 AM CEST kdex wrote:
> Can already be solved using decorators. Thus, no need for new syntax.
> If we get a standard library to import some common decorators from, one
> could easily write:
>
> ```js
> import { memoize } from "std::decorators";
> @memoize
> function sum(a, b) {
> return a + b;
> }
> ```
>
> On Wednesday, June 21, 2017 12:58:43 AM CEST Guy Ellis wrote:
> > I have an idea rattling around that allowing the developer to mark a
> > function as deterministic would allow the compiler to determine if a
> > speed/memory memoization trade-off will improve performance.
> >
> > Possible syntax:
> >
> > deterministic function sum(a, b) { return a + b; }
> >
> > Use case:
> >
> > I can only think of one right now: compiler memoization
> >
> > Why not a memoization library?
> >
> > I'm not a compiler expert. I've read that today's compilers are doing
> > optimizations at runtime based on call frequency and other metrics that
> > they collect. If a compiler knows that a function is deterministic it will
> > be able to use call time metrics against the return value size to
> > determine
> > if memoization should be done on specific calls.
> >
> > I think (I could be completely wrong here) that the compiler has access to
> > memory metrics that a memoization library would not have access to in
> > order
> > to optimize this on-the-fly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170621/682c9600/attachment.sig>
More information about the es-discuss
mailing list