This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-10
Channels
- # announcements (3)
- # babashka (16)
- # beginners (41)
- # biff (4)
- # calva (14)
- # circleci (1)
- # clj-http (24)
- # clj-kondo (9)
- # clj-on-windows (31)
- # cljs-dev (52)
- # clojure (162)
- # clojure-australia (10)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-spec (1)
- # clojure-uk (5)
- # clojurescript (40)
- # conjure (6)
- # core-async (3)
- # cursive (5)
- # datalevin (11)
- # datomic (7)
- # emacs (12)
- # etaoin (19)
- # events (1)
- # figwheel-main (17)
- # fulcro (4)
- # graalvm (3)
- # gratitude (13)
- # honeysql (8)
- # introduce-yourself (7)
- # london-clojurians (1)
- # off-topic (9)
- # polylith (9)
- # rdf (1)
- # re-frame (21)
- # releases (5)
- # remote-jobs (4)
- # sci (28)
- # shadow-cljs (15)
- # spacemacs (2)
- # vim (4)
- # xtdb (15)
new version of http://getclojure.org is up backed by elasticsearch. It's so cool to have SCI because many things like (defn …) were barred from running in clojail, but not so in SCI. As a result the set of expressions that run successfully tripled to around 57,000
for most queries the first page will bore you, and the last page for the query will be… interesting
There's some cleanup to do and ranking to do for short exprs and as you mentioned things which return fns and such, but I just cracked up when I searched for iterate. Go to the last page.
If someone runs some code to defmethod print-method for say string, this winds up in the subsequent results
(sci/eval-string "(defmethod print-method String [obj w] (.write w (str \"I'm a string: \" obj)))")
(with-open [w (new StringWriter)]
(sci/binding [sci/out w]
(let [res (sci/eval-string "(println \"hello\")")]
(str w))))
err I should be a bit more clear: it’s not “wrong” per se, but from a “treating SCI as if it’s a sandbox” standpoint, it feels like there is an assumption of a clean context on subsequent runs that doesn’t hold here
i know SCI doesn’t necessarily claim to be a sandbox, but for instance
(sci/eval-string "(defn foo [x] (inc x))")
(sci/eval-string "(foo 1)")
rightly fails to resolve symbol fooYeah, you could either remove print-method or SCI could fix it. The first time I hear this issue. Sandbox is a feature of SCI
it’s a pretty weird one, and i blame chouser for writing this in clojure IRC in like 2011 😄
i think im inclined to dig into what it would take to fix it, but of course disallowing it is an option
it feels like an oddity in that it survives separate envs and someone could register print-method and muck up future evaluation
lmk if there’s anything I can add for context. I’m also happy to take a whack at it. I’m very interested in the “why” of the issue.
The why of the issue is that print-method in SCI directly uses the Clojure one and that one uses a global hierarchy
i wonder if it’s too involved/causes issues to somehow cleanse the global hierarchy across evaluations
That's one of the solutions I was thinking of. Another solution would be to use the hierarchy in the context and make a custom print method
If you're concerned about security, there's still probably some functions or vars that should be off-limit no? print-method might be one of them
@didibus most of those things are already not included by default, but print-method slipped through :)
We already have a custom print-method in SCI: https://github.com/babashka/sci/blob/afc1c010a71a0640a3c4466b7b3a1cce0ad88eee/src/sci/impl/io.cljc#L14 So if we could get access to the ctx + the ctx hierarchy there, we could solve it properly