What was drawing me to this idea is that the compiler is already doing performance optimization and a typical performance optimization is memoization. If the compiler were aware that it could memoize the results of a function it could determine this on-the-fly in a way that a library would not be able to. i.e. the compiler has access to metrics that the library does not have access to. I'm theorizing that the compiler could significantly outperform a library based solution here. Do you think that there might be any validity to that theory?
On Tue, Jun 20, 2017 at 4:11 PM Guy Ellis <[email protected]> wrote: > @kdex I initially thought of decorators but did not know that there were > plans for a standard library that compilers would be "aware of" and would > be able to draw this from. Thanks! > > On Tue, Jun 20, 2017 at 4:03 PM kdex <[email protected]> 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._______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

