[racket-users] Re: Best way to write run-once-and-cache functions?

2017-04-26 Thread Jack Firth
A `define/delay` macro for this might be a good addition to `racket/promise`: (define-simple-macro (define/delay id:id expr:expr) (begin (define p (delay expr)) (define (id) (force p (define/delay conf (with-input-from-file "db.conf" read-json)) (conf) ;; forces promise -- You

[racket-users] Re: Best way to write run-once-and-cache functions?

2017-04-25 Thread Alex Harsanyi
On Wednesday, April 26, 2017 at 12:12:26 PM UTC+8, David K. Storrs wrote: > > I could do it with a parameter but that's only sweeping the above ugliness > under the rug: > > (define conf (make-parameter #f)) > > (define (read-conf) >    (or (conf) > (begin >    (conf