Arc Forumnew | comments | leaders | submitlogin
3 points by almkglor 5903 days ago | link | parent

Hmm. What I'm currently planning is to have 'tofile and 'fromfile tagged arguments instead:

  (def file-table-w/read (path)
    (file-table path
                'tofile    [tostring (write _)]
                'fromfile  read))
Then memoization will be done on the file-contents (ct and mt) tables instead of actual file-table objects.

It would be useful also to have non-memoized versions, accessible via 'nocache:

  (def grep* (rex path)
    (zap re rex)
    (accum collect
      (ontable k v (file-table path 'nocache)
        (if (re-match rex v) (collect k)))))
'nocache would be useful for such cases where you want to scan through files but not cache their actual contents.

It might also be useful to store cached contents only for a certain time, to preserve memory (but then gc will get run anyway).

p.s. supporting tagged options will make an optional path argument difficult. I suppose I can check if the first argument is a string, though, and treat it as the path if it is.