Derrp yes that should be in the returned expression itself. No worries I’ll take another crack at it. Thanks. Sorry no coffee in me yet. I also forgot to quote the remove file in the free_memo macro - yikes.
Here this should be better
using JLD2
macro memoize(cache_var)
filename = String(cache_var) * ".jld2"
quote
if !isfile( $filename )
@save $filename $cache_var
else
@load $filename $cache_var
end
end
end
macro memoize(cache_var, fn)
filename = String(cache_var) * ".jld2"
quote
if !isfile( $filename )
$fn
@save $filename $cache_var
else
@load $filename $cache_var
end
end
end
macro free_memo(cache_var)
filename = String(cache_var) * ".jld2"
quote
if !isfile( $filename )
@warn "Cache is already empty."
else
rm($filename)
end
end
end