danilopedraza / komodo

The Komodo programming language code repository
https://komodo-lang.org/
GNU General Public License v3.0
7 stars 0 forks source link

Memoization #47

Closed danilopedraza closed 1 month ago

danilopedraza commented 4 months ago

I forgot about memoization. I need to define a syntax to remember previously computed values of a function.

danilopedraza commented 2 months ago

I propose this: When you want to memoize a call, you mark it with the save keyword:

let fib(0) := 0
let fib(1) := 1
let save fib(n) := fib(n - 1) + fib(n - 2) # calls that match this pattern will be memoized
TheComputerCat commented 1 month ago

I do not like this word. It could be confusing, I thought,save just saves the return value of the function. I think It would be better to use a word that makes the user think about the memoization process, not just about saving.

danilopedraza commented 1 month ago

Yeah, I think I will go with memoize.

danilopedraza commented 1 month ago

This is naively implemented and tested now.