This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-05
Channels
- # announcements (17)
- # aws (1)
- # babashka (68)
- # beginners (88)
- # calva (85)
- # chlorine-clover (10)
- # cider (5)
- # cljsrn (4)
- # clojure (99)
- # clojure-android (1)
- # clojure-denmark (1)
- # clojure-europe (15)
- # clojure-italy (5)
- # clojure-nl (3)
- # clojure-spec (1)
- # clojure-uk (67)
- # clojurescript (44)
- # core-async (44)
- # cryogen (4)
- # cursive (22)
- # data-science (2)
- # datascript (10)
- # datomic (29)
- # duct (11)
- # editors (2)
- # emacs (2)
- # events (1)
- # fulcro (28)
- # ghostwheel (7)
- # graalvm (8)
- # instaparse (6)
- # java (34)
- # jobs (9)
- # jobs-discuss (71)
- # juxt (12)
- # luminus (3)
- # malli (15)
- # meander (9)
- # nrepl (4)
- # off-topic (44)
- # pathom (13)
- # reagent (22)
- # schema (1)
- # shadow-cljs (39)
- # spacemacs (2)
- # test-check (1)
- # tree-sitter (5)
- # xtdb (5)
- # yada (1)
Btw I found something about a Truffle interpreter in Clojure http://epub.jku.at/obvulihs/download/pdf/501665 I think I’ll ask him for an opinion on Sci
One of the questions about Truffle things is if it would allow evaluating code at runtime in a natively compiled binary. Truffle is nice for interop in a shared polyglot runtime, but this is a different thing from evaluating programs from strings at runtime in a binary afaik.
Good point indeed
@jeroenvandijk nice! we'd seen: http://ssw.jku.at/Teaching/MasterTheses/Graal/TruffleClojure.pdf but not the completed thing!
may be the link can be updated at: https://github.com/lread/clj-graal-docs/blob/master/doc/external-resources.md
@sogaiu I randomly googled “truffle clojure” and I found that thesis and also this twitter thread https://twitter.com/alandipert/status/650843148986527744
I read a post somewhere by the GraalVM people that it was based on an older version of Truffle
same here
I think that’s the proposal for the thesis that was written in 2015, so must be close to that
both issues fixed (tests pass at least), plus another one I found: https://github.com/borkdude/sci/pull/282
Does anyone see what is wrong with this? (trying from a browser console):
sci.evalString('(js/alert "foo")', {"classes": {"js": window, "allow": "all"}, "allow": "all" })
Gives
message: "js/alert is not allowed! [at line 1, column 2]"
(i added allow
at multiple places to prevent this error)Maybe {"allow": "all"}
is not the same as the internal {:allow :all}
Yeah could be. I’ll try to make a debug version of Sci to confirm this
it's an undocumented workaround anyway, might change it, since there might be a class called "allow"
in JS which would then clash
maybe it has to be a namespaced key that has a truthy value, so anything except false or null will work
the checking is done for two reasons: 1) you might want to limit access to a class. 2) when there is no check in GraalVM you just get some weird exception because the reflection information is missing
yeah the check makes sense, in js probably as well. I’ll try to debug it
ok it was something else https://github.com/borkdude/sci/pull/283/commits/be2f25385c63625824ba5064933ed13bf98ec2ec
made another pull request with this addition
I guess browser tests are needed 😬
we have node tests, why is that not sufficient? I'm not sure if I want to take on a dependency. can you just copy/inline that call function from the lib if needed?
yeah thought about that, but it is not a oneliner so I decided to add the dependency
It has several layers
Either way it’s a proof that it can work
for me at least 🙂
I can also fork Sci and make a browser version
browser tests are fine, but also brittle. I have browser tests for https://github.com/borkdude/re-find.web. maybe you can take a look at those
the part where the copying became unattractive starts here https://github.com/appliedsciencestudio/js-interop/blob/master/src/main/applied_science/js_interop.clj#L123
Maybe the actual thing that is needed is actually smaller, but I am happy that I finally made it work
yep, trying now
ok seems to work as well 🙂
I removed the js-interop dep again
(gobj/get class method-name)
that expression is already there, it's called method
in the if-let
I think this is what I had before. So some methods need also the class, but some don't. I wonder how one can determine that.
yeah I guess it can be cleaned up. Ok i have to go. Will look into it later
btw, probably why apply
doesn’t always work is described here https://medium.com/@jhawleypeters/javascript-call-vs-apply-vs-bind-61447bc5e989 AKA the horror of javascript
yeah... I think I hit that before without knowing it. maybe it's better to avoid this crap altogether
Hopefully we can fix it once and never have to deal with it again 🙌
pooh yeah probably. I cannot go into this rabbithole 🙈 I just want some clojure in my browser haha. But good news, the apply thing seems to work for now. Browser tests will definitely help to iterate faster I’m copy pasting the minified thing to my project now and do manual tests
thanks