On Wednesday, April 26, 2017 at 9:48:56 AM UTC-7, David K. Storrs wrote: > On Wed, Apr 26, 2017 at 12:21 AM, Jon Zeppieri <[email protected]> wrote: > I don't know that there's a right way, but if your functions are > > nullary, then promises are a decent fit: > > > > (define conf > > (delay > > (with-input-from-file ...))) > > > > Then just (force conf) whenever you want the value. > > > > Yeah, that works well. Thanks! > > > Any thoughts on how to do it for non-nullary functions?
For non-nullary functions, you're looking for memoization / caching. There's a couple packages that do this, along with relate - In the `sugar` package, the `sugar/cache` module gives you exactly this, in the form of a `define/caching` macro. - The `tmemoize` package provides similar functionality for Typed Racket functions. - The `with-cache` package gives you promise-like behavior for thunks that use an external storage system. - The `remember` package gives you caching behavior for compile-time expressions that can be remembered across compilation runs. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

