@borkdude thanks, I already thought of something similar, just doesn't make the code very nice. Thanks anyway. The this-as macro I had also seen in clojurescript, thought maybe I could somehow implement this macro myself in skittle (but I haven't really written macros myself yet and in SCI it seems to work a bit differently somehow). I'm also not sure if this macro could be implemented in SCI or skittle at all.
scittle is spelled with a c, not a k. Why does everybody spell it with a k... you're not the first one this week :)
ohhh sorry
no problem, just wondering why people do this 😆
Skittles sounds like a tasty piece of chocolate 🍫 Isn't there something called "skittles"?
👍
no idea 😂 maybe because I'm german
unfortunately this-as isn't easy to implement in SCI because SCI is an interpreter, not a compiler. In a compiler it's much easier to implement this-as since you can just emit (let [x this] ...) basically, but in SCI this isn't as easy
I have tried the following yet now. This works, what do you think?
(defn object [p ms],
(js/scittle.core.eval_string
(str `(let [this ~p]
~@(for [[k m] ms]
`(aset this (name ~k) ~m))
this))))
(defn Foo []
(object
#js {:x 1
:y 2
:z 20}
{:test `(fn [] (.-z this))}))You could maybe also do this using a macro.
(defmacro do-with [[obj binding] & body]
`(let [~binding obj] ~@body ~binding))
(do-with [this #js {:a 1}] (set! (.-foo this) (fn [] (.-z this))))
;;=> #js {:a 1 :foo ...} There is also the doto macro in clojure which you could maybe use
but yeah, that seems like a good approach
If you can, you should try to avoid eval by writing a macro
ok, thanks
that's why i didn't find the channel yesterday. that's why i asked my question in babashka.
Perhaps it's possible, feel free to look into this
ok, I'll probably have to spend more time with SCI. But your projects are really ingenious. Very great work from you.
skittle ... a popular brand of sweets also things you throw balls at
<script crossorigin src=""></script>
<script crossorigin src=""></script>
When I try this and open my html file with a browser I get CORS policy error. What is the best way to include those scripts?do you serve the file via a server or via the file system?
my html file is filesystem
try a server:
bbin install io.github.babashka/http-server [benj@benj-pc scittle-prints-itself]$ [benj@benj-pc scittle-prints-itself]$ http-server --help
Cloning:
Error building classpath. Unable to clone /home/benj/.gitlibs/_repos/ssh/github.com/babashka/sci.nrepl.git
: Permission denied (publickey).
looks wrong. I'm guessing this is a tools issue
ah lol it's because I have something wrong at bb.edn in the directory I thinkhmm, I don't know what this is... @rads an idea?
you could also use http-server directly without going through bbin
yea.
but it was that I had in bb.edn
that was the issue
ok
it's just that bb pulls stuff with clj-tools when you invoke in the dir with bb.edn. And then I was confused because no connection to http-server
🎉
@rads has joined the channel