This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-27
Channels
- # announcements (11)
- # aws (1)
- # babashka (15)
- # beginners (345)
- # calva (5)
- # chlorine-clover (14)
- # clj-kondo (40)
- # cljfx (30)
- # clojure (174)
- # clojure-australia (6)
- # clojure-europe (64)
- # clojure-france (1)
- # clojure-nl (12)
- # clojure-uk (20)
- # clojurescript (29)
- # conjure (1)
- # core-async (53)
- # cryogen (3)
- # cursive (8)
- # datomic (12)
- # emacs (5)
- # events (4)
- # fulcro (27)
- # graalvm (1)
- # graphql (9)
- # helix (8)
- # keechma (11)
- # london-clojurians (1)
- # malli (12)
- # off-topic (12)
- # pathom (8)
- # portal (1)
- # re-frame (19)
- # reagent (13)
- # reitit (16)
- # ring-swagger (2)
- # sci (38)
- # shadow-cljs (31)
- # spacemacs (3)
- # specter (14)
- # sql (14)
- # tools-deps (31)
- # vim (4)
- # xtdb (9)
Hey all! had a Q for the group - if I already have a quoted form, is there a way to not roundtrip through string and gain some efficiency?
@sritchie09 Sci supports eval-form
. It is a lower level primitive.
user=> (require '[sci.core :as sci])
nil
user=> (def ctx (sci/init {}))
#'user/ctx
user=> (sci/eval-form ctx '(+ 1 2 3 ))
6
awesome!
thanks @borkdude
@borkdude do you recommend creating a new context for each eval
call, if I'm not attempting to persist state?
ie is there some efficiency gain to creating it once, even if I don't want to communicate info across eval calls
you can also use sci/init
+ sci/fork
. Fork will create a new ctx from the state of the ctx given
it depends, like, if you're doing 100s of evals per second, then it makes sense to pre-create the context once
the setting here is a scientific computing package, where I have
• some super nested physics functions written in terms of generic operations,
• I pass in 'x
and get back a big evaluation tree that I simplify,
• once everything's simplified I eval-form
once, then use the compiled function a bunch
so probably doesn't matter too much here, but it's easy to do
@borkdude eval-form
must be in the latest alpha yeah?
it might not have been published to clojars as an alpha. can do that, if you need it
I'm currently still in leiningen land, and all of my build knowledge is rip-van-winkled in from 2015 🙂
that would be awesome
I'll convert to deps.edn
soon, but this would be really helpful
@borkdude also THANK YOU for writing sci!!!!
I've been on this months-long push to get https://github.com/littleredcomputer/sicmutils converted to Clojurescript as part of my larger "dynamic notebooks" project, basically a lightweight mathematica-style interface in the browser, etc etc
and the ability to simplify and live-compile functions down in a cljs browser environment is a hard requirement... I thought I'd be stuck in prototype land with a self-hosted-cljs requirement
excellent thank you!
@sritchie09 Hmm, deploy failed due to token I have to refresh. One minute
looks like it made it up
@sritchie09 If you're adopting sci, feel free to list your project here as well: https://github.com/borkdude/sci#projects-using-sci
sg, will send a PR shortly
amazing... a differential equation simulation goes from 4 seconds to 80ms in clojurescript now that I can apply simplifications inside the function
Hello! Can I use :allow to whitelist what's allowed to do, but also let the arbitrary symbols be used in defs?