(macro persist [handle literal]
(local (ok params?) (pcall (fn [] (require :params))))
(local params (if ok params? {:persist true}))
(if params.persist
`(local ,handle
(let [module# (or ... :entry-module)]
(print (string.format "Persiting %s %s" module# ,(tostring handle)))
(when (not _G._persist) (tset _G :_persist {}))
(when (not (. _G._persist module#)) (tset _G :_persist module# {}))
(when (not (. _G._persist module# ,(tostring handle)))
(tset _G :_persist module# ,(tostring handle) ,literal))
(. _G :_persist module# ,(tostring handle))))
`(local ,handle ,literal)))
(persist something-i-want-to-keep {:value 1})
(local somthing-that-should-reset {:value 2})
(fn example []
(print something-i-want-to-keep.a)
(print something-that-should-reset.a))
{: example}