scittle

leobm 2022-09-21T09:46:06.529849Z

@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.

borkdude 2022-09-21T09:46:41.139809Z

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 :)

leobm 2022-09-21T09:46:49.678559Z

ohhh sorry

borkdude 2022-09-21T09:47:05.137279Z

no problem, just wondering why people do this 😆

bherrmann 2022-10-02T13:46:20.143309Z

https://www.skittles.com/

bherrmann 2022-10-02T13:48:02.360629Z

🎯 1
teodorlu 2022-09-21T11:02:51.937039Z

Skittles sounds like a tasty piece of chocolate 🍫 Isn't there something called "skittles"?

leobm 2022-09-21T14:03:12.494689Z

👍

leobm 2022-09-21T09:47:27.030169Z

no idea 😂 maybe because I'm german

borkdude 2022-09-21T09:48:14.984899Z

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

leobm 2022-09-21T14:03:45.745099Z

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))}))

borkdude 2022-09-21T14:08:46.123589Z

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 ...}  

borkdude 2022-09-21T14:09:08.020479Z

There is also the doto macro in clojure which you could maybe use

borkdude 2022-09-21T14:09:13.310139Z

but yeah, that seems like a good approach

borkdude 2022-09-21T14:09:25.838039Z

If you can, you should try to avoid eval by writing a macro

leobm 2022-09-21T14:09:36.511469Z

ok, thanks

leobm 2022-09-21T09:48:16.728659Z

that's why i didn't find the channel yesterday. that's why i asked my question in babashka.

borkdude 2022-09-21T09:48:22.499689Z

Perhaps it's possible, feel free to look into this

leobm 2022-09-21T09:51:03.223039Z

ok, I'll probably have to spend more time with SCI. But your projects are really ingenious. Very great work from you.

❤️ 1
ray 2022-09-21T10:02:53.955529Z

skittle ... a popular brand of sweets also things you throw balls at

Benjamin 2022-09-21T10:21:06.575919Z

<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?

borkdude 2022-09-21T10:26:00.180239Z

do you serve the file via a server or via the file system?

Benjamin 2022-09-21T10:27:37.129169Z

my html file is filesystem

borkdude 2022-09-21T10:28:28.767609Z

try a server:

bbin install io.github.babashka/http-server 

Benjamin 2022-09-21T10:46:18.101339Z

[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 think

borkdude 2022-09-21T10:47:13.338249Z

hmm, I don't know what this is... @rads an idea?

borkdude 2022-09-21T10:47:28.054309Z

you could also use http-server directly without going through bbin

borkdude 2022-09-21T10:47:41.185369Z

https://github.com/babashka/http-server

Benjamin 2022-09-21T10:47:45.675829Z

yea.

Benjamin 2022-09-21T10:47:52.115689Z

but it was that I had in bb.edn

Benjamin 2022-09-21T10:47:57.686109Z

that was the issue

borkdude 2022-09-21T10:48:32.227949Z

ok

Benjamin 2022-09-21T10:48:34.915069Z

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

Benjamin 2022-09-21T10:50:16.027879Z

🎉

🎉 2
rads 2022-09-21T10:47:16.090969Z

@rads has joined the channel