We're getting a little far from my real question, since caching the examples is
IMHO a hack to cache the most expensive part of the computation, while the whole
'doc ought to be cachable, but....

I forgot what my own code was doing.
That's basically what I'm doing:
(define (make-cached-eval name . rest)
  (define ev
    (make-log-based-eval
     (cachefile name)
     (if (file-exists? (cachefile name))
         'replay
         'record)))
  (for ([r rest])
    (ev r))
  ev)

I'm using with-cache's `cachefile` just to generate and manage the file path, so
it ends up in have a good place.
I was trying to do something more complex earlier, but it didn't work.

On Wed, Mar 25, 2020 at 09:59:15PM +0100, Ryan Culpepper wrote:
> I'm not clear on what `with-cache` is doing in this setup, but it seems
> like a potential source of errors. If the goal is to automatically use
> `'replay` if the log file exists and `'record` otherwise, why not do the
> following?
> 
>     (make-log-based-eval the-log-file (if (file-exists? the-log-file)
> 'replay 'record))
> 
> Ryan
> 
> 
> On Wed, Mar 25, 2020 at 8:57 PM William J. Bowman <[email protected]>
> wrote:
> 
> > On Wed, Mar 25, 2020 at 08:51:18PM +0100, Ryan Culpepper wrote:
> > > You can use `raco make` (or `raco setup` for docs of installed packages)
> > to
> > > compile the Scribble files, but that won't compile the examples. Those
> > are
> > > dynamically evaluated when the Scribble documents are run.
> > Yeah, I was thinking of "compilation" as in caching the output document
> > from
> > each module.
> >
> > > For `make-log-based-eval`, are you using a separate evaluator (and
> > separate
> > > log file) for each Scribble file?
> > Yes. However, I'm using `with-cache` and a wrapper to detect whether a
> > cache
> > file exists (separate cache file each evaluator), and use 'replay mode if
> > the
> > cache file exists, so I don't have to manually switch to 'replay mode, or
> > manually re-record if I alter an example (instead, just clear the cache).
> >

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200325220252.GA31619%40williamjbowman.com.

Reply via email to