Arc Forumnew | comments | leaders | submitlogin
2 points by evanrmurphy 5090 days ago | link | parent

Hmmm... I was going to say it'd be nicer to put that save function in its own utility for a tidier 'disktem:

  (def temsave (tem file)
    (writefile (tablist tem) file))

  (mac disktem (var tem file)
    `(fromdisk ,var ,file (inst ',tem) [temload ',tem _] temsave))
Which you can do, but that 'temsave is isomorphic to (the already-existing) 'save-table:

  (def save-table (h file)
    (writefile (tablist h) file))
So could 'disktem be rewritten as the following?

  (mac disktem (var tem file)
    `(fromdisk ,var ,file (inst ',tem) [temload ',tem _] save-table))
If so, it has taught me something about templates: they're simply tables on writes/saves; it's on reads/loads that their difference manifests (as far as I/O is concerned, anyway). [1]

[1] And the same can be said for tables and alists, since tables get 'tablist-ed before they're written/saved. Neat!



1 point by evanrmurphy 5088 days ago | link

Minor revision of that last 'disktem definition:

  (mac disktem (var tem file)
    `(fromdisk ,var ,file (inst ,tem) [temload ,tem _] save-table))
The only difference is ,tem instead of ',tem for consistency with the other template utilities, which don't quote it.

Did more testing and the reliability seems good, in case anyone else wants this big ol' wart for their own arc's face. ;)

-----