This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-27
Channels
- # announcements (11)
- # asami (7)
- # babashka (140)
- # beginners (58)
- # calva (12)
- # clj-kondo (5)
- # cljsrn (9)
- # clojure (60)
- # clojure-australia (8)
- # clojure-boston (1)
- # clojure-europe (35)
- # clojure-france (2)
- # clojure-germany (5)
- # clojure-italy (8)
- # clojure-nl (7)
- # clojure-sweden (14)
- # clojure-uk (23)
- # clojurescript (16)
- # community-development (2)
- # cursive (7)
- # datomic (6)
- # docker (1)
- # emacs (4)
- # fulcro (11)
- # graalvm (5)
- # honeysql (6)
- # jobs (6)
- # jobs-discuss (36)
- # lsp (19)
- # malli (7)
- # meander (8)
- # off-topic (18)
- # pathom (16)
- # practicalli (33)
- # re-frame (43)
- # react (2)
- # remote-jobs (11)
- # sci (83)
- # shadow-cljs (55)
- # tools-deps (48)
any change of getting an utility to sci (or to a new single-purpose lib) to limit how long an sci eval can take millis? related to (https://github.com/borkdude/sci/pull/349)
it’s easy to go wrong in the user space and I think people copy&paste buggy limiters into user code bases to avoid this.
like I just inlined a code snipplet to malli, and just for cljs, and without proper threading….
#?(:clj
(defn ^:no-doc -run [^Runnable f ms]
(let [task (FutureTask. f), t (Thread. task)]
(try
(.start t) (.get task ms TimeUnit/MILLISECONDS)
(catch TimeoutException _ (.cancel task true) (.stop t) ::timeout)
(catch Exception e (.cancel task true) (.stop t) (throw e))))))
Please read this issue: https://github.com/borkdude/sci/issues/348 On the JVM you can do this by running sci in a thread and killing the thread. But sci itself doesn't have enough control over the host to facilitate this
@borkdude Thanks for directing me here - I looked but I must have failed to include a # sign or something like that, so I didn't see it.
I'm just starting to use sci
and I'm surprised that I can't eval something like: "^{:foo true}[1 2]" and see that metadata on the result returned by eval-string
.
Can you try to use the newest commit from master using a git dep? I think this was already fixed.
I'm going to revert to the release version of sci and see if it was my bug all along.
Ok, as embarrassing as it is to say, this looks like it was probably my error all along in how I was treating the value returned from sci
.
I'm using shadow-cljs
to build my project, and I see a couple of whiny warnings about not being able to infer target type.
The shadow-cljs warnings should be fixed on master as well I think. Are you still using the git dep?
I'm not using the git dep anymore, but I can test with that and see if the warnings go away. One sec.
------ WARNING #1 - :infer-warning ---------------------------------------------
Resource: sci/impl/vars$macros.cljc:107:14
--------------------------------------------------------------------------------
104 |
105 | (defn push-thread-bindings [bindings]
106 | (let [frame (get-thread-binding-frame)
107 | bmap (.-bindings frame)
--------------------^-----------------------------------------------------------
Cannot infer target type in expression (. frame -bindings)
--------------------------------------------------------------------------------
108 | bmap (reduce (fn [acc [var* val*]]
109 | (when-not (dynamic-var? var*)
110 | (throw (new #?(:clj IllegalStateException
111 | :cljs js/Error)
--------------------------------------------------------------------------------
------ WARNING #2 - :infer-warning ---------------------------------------------
Resource: sci/impl/vars$macros.cljc:131:21
--------------------------------------------------------------------------------
128 | (defn get-thread-bindings []
129 | (let [f (get-thread-binding-frame)]
130 | (loop [ret {}
131 | kvs (seq (.-bindings f))]
---------------------------^----------------------------------------------------
Cannot infer target type in expression (. f -bindings)
--------------------------------------------------------------------------------
132 | (if kvs
133 | (let [[var* ^TBox tbox] (first kvs)
134 | tbox-val (t/getVal tbox)]
135 | (recur (assoc ret var* tbox-val)
--------------------------------------------------------------------------------
in general shadow warnings don't really hurt but it would be nice to get rid of them. I'll take a look
In sci
is it possible to do things like create a new javascript date in clojurescript?
@pmooser You can. The config for this you can borrow from: https://github.com/babashka/xterm-sci which is hosted here: https://babashka.org/xterm-sci/
Welcome to xterm-sci.
user=> (js/Date.)
#inst "2021-04-27T10:00:05.412-00:00"
user=>
I'm not getting any replies from #shadow-cljs, I think I'll just go ahead with the release
@pmooser Can you do one more check with commit 45a3363cc0dc09f9d6e50c7ec88fe29612597c79
to see if this fixed the warning?
------ WARNING #1 - :infer-warning ---------------------------------------------
Resource: sci/impl/vars$macros.cljc:131:21
--------------------------------------------------------------------------------
128 | (defn get-thread-bindings []
129 | (let [f (get-thread-binding-frame)]
130 | (loop [ret {}
131 | kvs (seq (.-bindings f))]
---------------------------^----------------------------------------------------
Cannot infer target type in expression (. f -bindings)
--------------------------------------------------------------------------------
132 | (if kvs
133 | (let [[var* ^TBox tbox] (first kvs)
134 | tbox-val (t/getVal tbox)]
135 | (recur (assoc ret var* tbox-val)
--------------------------------------------------------------------------------
ok, it seems shadow-cljs doesn't understand return tags from get-thread-binding-frame
Is it correct that in cljs right now, with sci, the story with things like println
is ... we should bind them ourselves to the normal cljs println ? (or some other function that does whatever we want it to do).
By default calling println seems to result in an opaque exception, but I see an issue in github regarding cljs printing.
yeah, sci is "safe" by default and doesn't let you mutate the outside world by default.
Ah yes. I just meant I hadn't had any luck binding sci/out to *out*
in cljs or whatever.
It's ok - the example from xterm-sci is really nice, including the goog string buffer which is obvious in cljs.
It's a great starting point, and when I dig into it, if I really get stuck, I'll ask you, but the working example is definitely great.