This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-14
Channels
- # asami (1)
- # babashka (50)
- # beginners (70)
- # bristol-clojurians (6)
- # calva (36)
- # chlorine-clover (1)
- # cider (4)
- # clj-kondo (3)
- # cljdoc (49)
- # cljsrn (5)
- # clojure (96)
- # clojure-australia (3)
- # clojure-dev (1)
- # clojure-europe (84)
- # clojure-nl (4)
- # clojure-spec (9)
- # clojure-uk (65)
- # clojurescript (31)
- # community-development (6)
- # conjure (17)
- # cursive (8)
- # datascript (5)
- # datomic (12)
- # duct (3)
- # emacs (18)
- # figwheel-main (2)
- # fulcro (7)
- # helix (1)
- # jobs (3)
- # luminus (7)
- # off-topic (77)
- # pathom (3)
- # portal (1)
- # rdf (4)
- # re-frame (1)
- # reitit (4)
- # remote-jobs (4)
- # reveal (15)
- # rum (1)
- # sci (38)
- # shadow-cljs (22)
- # spacemacs (1)
- # specter (6)
- # sql (1)
- # test-check (1)
- # tools-deps (60)
- # vim (12)
@borkdude Hi, I have finally released https://github.com/JeremS/prose. The eval-form
function going in the main API helped a lot. Thanks again for helping with my questions.
@jeremys if you want, you can add it to the list here: https://github.com/borkdude/sci#why
👋 Is it theoretically possible to round-trip an sci context to edn between evaluations with the proper reader extensions?
@jfntn I don't think so since the context contains reference to values like functions
I was wondering if it would be possible to pause and resume an evaluation session by just storing and restoring the context
https://tech.redplanetlabs.com/2020/01/06/serializing-and-deserializing-clojure-fns-with-nippy/
@jfntn Another idea: store the incoming expressions so you can build up the state next time
Nippy seems to be having a hard time with the run-fn
returned by sci.impl.fns/parse-fn-args+body
(-> sci-ctx :env deref :namespaces (get 'user) (get 'foo) )
;; => #<SciVar@2fa20b2d: #function[sci.impl.fns/parse-fn-args+body/run-fn--25249]>
(-> sci-ctx :env deref :namespaces (get 'user) (get 'foo) nippy/freeze)
Execution error (NoSuchFieldException) at java.lang.Class/getField (Class.java:2013).
meta
I assume you're using this lib? https://github.com/redplanetlabs/nippy-serializable-fns
This seems more straightforward, the downsides being you'd have to re-evaluate all expressions every time you want to resume a context
Wondering if this is the right approach though... sci.impl.fns/parse-fn-args+body
will return fns that call back into sci's eval, so we'd need to close over a big chunk of the whole interpreter for every function in the env.
Realized this was the case while digging into the nippy exception, which seems to happen when trying to serialize the eval-do*
that was passed to parse-fn-args+body
true, they are closures holding on to the interpreter, since their bodies need interpretation
Right so I think the issue here is that I need to extend nippy's freeze and thaw for all the sci datatypes (Var, Namespace etc)
Yep, which might not be that hard, but they are implementation details which could change over time
Actually it's not just sci, also requires supporting freeze/thaw for e.g. clojure.lang.Atom since it's part of the env being closed over
Right, but the custom data types are inside the atom so it makes for a confusing mix of print-method and freeze/thaw extensions, can probably figure this out though
Trying to freeze the ctx now and getting a stack overflow on the first SciVar for a fn, actually not sure this is workable since there's a circular dependency between the ctx and the functions that closer over it