(local {: format} string) (fn ->str [x] (tostring x)) (fn head [xs] (. xs 1)) (fn fn? [x] "Returns whether the parameter(s) is a function. A function is defined as any list with 'fn or 'hashfn as their first element." (and (list? x) (or (= `fn (head x)) (= `hashfn (head x))))) (lambda gensym-checksum [...] "Generates a new symbol from the checksum of the object passed as a parameter. The parameter first is casted into a string using the function `fennel.view`. If only one parameter is passed to the function the return value is the checksum as a symbol. If two parameters are passed, the first one is considered the prefix. If three parameters are passed, the first one is considered the prefix and the last one is considered the suffix. This function depends on the md5 library and the fennel library." (match [...] [prefix object suffix] (let [{: view} (require :fennel) {:sumhexa md5} (require :md5)] (sym (.. prefix (md5 (view object)) suffix))) [prefix object] (gensym-checksum prefix object "") [object] (gensym-checksum "" object ""))) (lambda vlua [x] "Return a symbol mapped to `v:lua.%s()`, where `%s` is the symbol." (assert-compile (sym? x) "expected symbol for x" x) (format "v:lua.%s()" (->str x))) {: fn? : gensym-checksum : vlua}