clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Simon 2021-06-17T00:20:10.291900Z

Thank you!

West 2021-06-17T00:50:35.292100Z

(defonce blog-posts (r/atom '()))

(defn get-json
  [uri]
  (->
   (js/fetch uri)
   (.then (fn [res] (js->clj (.json res) :keywordize-keys :true)))
   (.catch (fn [err] (.log js/console err)))))

(-> (get-json all-posts-uri)
    (.then (fn [posts]
             (for [post posts]
               (let [post-uri (uri post)]
                 (->
                  (get-json post-uri)
                  (.then (fn [post] (swap! blog-posts conj post)))))))))
Ok, that was a bit hard to reason about, but this seems to work. This whole callback business makes me have to think of things backwards in a way.~ Very weird. Note: the uri and all-posts-uri are not in the snippet.

craftybones 2021-06-17T02:46:10.293500Z

Is there a difference between (vec (concat v1 (repeat n x))) and (vec (take n (concat v1 (repeat x))) ?

craftybones 2021-06-17T02:46:18.293900Z

I’m facing a weird problem that I am unable to understand.

craftybones 2021-06-17T02:46:38.294400Z

I’m iterating over a sequence and generating divs contained in a flex(reagent).

craftybones 2021-06-17T02:47:18.295200Z

When the sequence is generated with the first form above, the flex renders with the correct wrapping. The second form has a margin that I can’t explain. And there is absolutely no other difference in the code

craftybones 2021-06-17T02:50:07.296200Z

This makes no sense, but here is some reference

craftybones 2021-06-17T02:50:31.296700Z

the dom is the same, the styles are the same. I’m completely stumped as to what is happening

dpsutton 2021-06-17T02:57:19.298500Z

Seems like there is a difference in that in general. Consider if v1 has more elements than n. Your resulting sequence would have 0 x’s and in the first form would have n x’s

craftybones 2021-06-17T03:00:09.299400Z

It is not the same n between the two forms

craftybones 2021-06-17T03:00:28.299900Z

the n in the first form is (- total-n (count v1))

craftybones 2021-06-17T03:00:41.300200Z

whereas in the second form it is total-n

craftybones 2021-06-17T03:01:36.301300Z

My issue isn’t with the number of elements or the content of elements per se. It seems to have something to do with the iteration across the type, and I am unable to understand why or what. There is no reason why two exact same sequences should render differently just because they were generated differently

craftybones 2021-06-17T03:02:56.302800Z

Assuming (= v1 v2) , then (for [x v1] [some-component x]) should necessarily equal (for [x v2] [some-component x]) given that some-component is pure

phronmophobic 2021-06-17T03:03:20.303300Z

how have you confirmed that v1 and v2 are equal?

craftybones 2021-06-17T03:03:53.304400Z

I’ve checked both content and type. Both (= v1 v2) and (= (type v1) (type v2))

phronmophobic 2021-06-17T03:04:00.304700Z

when you check the resulting dom in the devtools inspector, what's the cause of the extra padding/margin?

craftybones 2021-06-17T03:05:45.305500Z

@smith.adriane - that’s the weird part. Every computed property is the exact same!

craftybones 2021-06-17T03:06:06.305900Z

all the margins, padding, borders are the exact same.

craftybones 2021-06-17T03:06:16.306200Z

I’m using a flex-wrap

phronmophobic 2021-06-17T03:07:56.306600Z

the computed properties are the same for each component and for the parent?

craftybones 2021-06-17T03:08:04.306800Z

Yeah. Exact same!

phronmophobic 2021-06-17T03:08:14.307Z

I don't believe you 😛

phronmophobic 2021-06-17T03:09:01.307300Z

are there the same number of child elements in each case?

craftybones 2021-06-17T03:12:03.308500Z

Argh. Thanks @smith.adriane - The problem was with the count. The last div was an empty div in one of the cases that was being added by some other event 🙂

🎉 1
craftybones 2021-06-17T03:12:28.309Z

Spent the last half an hour losing my hair on this and I’ve such little hair left to begin with

chepprey 2021-06-17T23:23:20.405Z

"can't style s##t"

craftybones 2021-06-17T03:12:36.309400Z

Thanks a ton. we totally forgot about it

phronmophobic 2021-06-17T03:13:52.309500Z

this matches my experience with CSS

➕ 1
craftybones 2021-06-17T03:15:18.309700Z

For some vague reason when the flex has only enough elements to fill a row without any spillovers it borks the margins. CSS - Clearly Screwball S**t

😂 1
Hlodowig 2021-06-17T04:24:43.310600Z

Wacky question, is it possible to develop a Chrome extension in Clojurescript?

👍 1
indy 2021-06-17T04:37:30.310700Z

https://github.com/binaryage/chromex

👍 1
1
Marcus 2021-06-17T07:02:55.312100Z

Hi! 🙂 Which libraries do you use for working with numbers and time (parsing, formatting, validation, manipulation etc)?

2021-06-17T08:09:36.314100Z

I am transitively using foreign-libs (through a cljsjs package). This package has declared :file and :file-min , but it doesn't use the minified file when I do advanced compilation. How is this decided, and does it work transitively?

2021-06-17T08:14:54.314400Z

Maybe https://www.juxt.land/tick/docs/index.html could be of interest? It's "java.time in cljs", which is a pretty good place to start.

Marcus 2021-06-17T08:49:18.314800Z

perfect @magnars thanks! 🙂

2021-06-17T09:16:07.315200Z

according to the docs: https://clojurescript.org/reference/compiler-options:file-min (Optional) Indicates the URL to the minified variant of the library. This will be used in preference to `:file` if `:optimizations` is set to either `:simple` or `:advanced`. sounds like a bug if that's not working

2021-06-17T09:36:23.315500Z

I agree, but I'm not sure where to start looking.

Tomaz Bracic 2021-06-17T09:57:44.315800Z

hi

Tomaz Bracic 2021-06-17T10:04:27.321700Z

I am really new to Clojurescript (and Clojure for that matter) and would like to ask the community 🙂 few things. So, I am looking around what could I start using as alternative to pure JS (React) and Typescript. Those are last on my list. I was really into Elm for a while, but elm community has some other problems too I could say. What I would like here is if I would go with Clojurescript... can I distance myself from NPM problems, how is with refactoring projects after a while. Is it any better by using CS or is pretty much the same as if I would work with React? I assume Reagent and similar follow development of React so there are changes? I read somewhere that this CS ecosystem is pretty much stable for the last 7 years... This type inference to what degree can i rely on it? With Elm ... you really get a lot of safety, but with the cost of decoupling JS World a lot and only allow interoperability via Ports

Tomaz Bracic 2021-06-17T10:04:50.322200Z

How good is CS for bigger projects?

2021-06-17T10:06:51.322400Z

jira, small repro and crack open the compiler are where I've looked next for this kind of thing

2021-06-17T10:07:49.322600Z

http://ask.clojure.org does not seem to be monitored for clojurescript, but in theory that's another option

Tomaz Bracic 2021-06-17T10:36:45.323400Z

What I meant with "can i rely on it' ... can I do something like compiler driven development.... ? like in elm?

borkdude 2021-06-17T10:52:38.325500Z

@tomaz.bracic Type inference is mostly used for performance in CLJS, not for safety. In the CLJS or Clojure in general ecosystem there are a few tools / linters (e.g. clj-kondo) that can help you avoid making silly mistakes, but they don't provide a static type system. There is also #lsp which can help you navigate projects. If you use #calva you get both tools integrated into VSCode, which may be a good way to start, but you can make it work with any editor really. To get "safety" it's best to write a test suite. There are also runtime validation libraries like #clojure-spec and #malli which can help you. Another piece of advice: if you don't know the CLJS tooling well, start with #shadow-cljs. This makes it easy to integrate with NPM libraries, but if you are using JS libraries from NPM, naturally you are going to get the pain of breaking changes from that ecosystem. CLJS is very good for big projects. I've been working on a big project for 5 years and if I would start over, I would pick CLJS again. For bigger apps, it might also be good to look into #re-frame if you are using #reagent.

Tomaz Bracic 2021-06-17T10:59:41.327100Z

O @borkdude I really appreciate your feedback. Thanks!

borkdude 2021-06-17T11:00:00.327400Z

@tomaz.bracic You might want to watch this talk: https://www.youtube.com/watch?v=geeK1-jjlhY

borkdude 2021-06-17T11:00:20.327800Z

(and wow, the youtube url has geeK in it)

Tomaz Bracic 2021-06-17T11:03:41.328500Z

yea... I saw this. Nice talk... though I was a bit shocked at the beginning because my other tech is Elixir too 🙂

borkdude 2021-06-17T11:04:08.329Z

So what are the problems you perceive in the elm community?

borkdude 2021-06-17T11:04:21.329400Z

Just out of curiosity.

Tomaz Bracic 2021-06-17T11:04:26.329700Z

i will have a heavy websocket based app. Elm removed support for those with 0.19 version... so you have to use ports now

Tomaz Bracic 2021-06-17T11:04:51.330200Z

I saw Sente library

borkdude 2021-06-17T11:05:02.330600Z

Remove support for websockets...?

Tomaz Bracic 2021-06-17T11:05:18.331300Z

yes, from the core. You deal with those via ports

Tomaz Bracic 2021-06-17T11:05:23.331600Z

it works quite ok

Tomaz Bracic 2021-06-17T11:05:57.332600Z

but yea... 🙂 this decoupling from JS brings a lot of great benefits but "problems" too.

borkdude 2021-06-17T11:06:30.333800Z

That's at least one problem you don't have to worry about in CLJS land: removing = breaking and the Clojure community (inspired by its BDFL) has a culture of not breaking, only accreting.

Tomaz Bracic 2021-06-17T11:07:09.334600Z

just need to figure it out what would be better. Still can't really shake off the feeling that the whole clojure(script) dev environment is huge... not really light. All those repl configurations, etc. Just my first impression

Tomaz Bracic 2021-06-17T11:07:25.335200Z

based on the fact... that I just stepped into this

borkdude 2021-06-17T11:07:30.335300Z

@tomaz.bracic FWIW, I don't even use a REPL for my (browser) CLJS projects, I just rely on hot-reloading

☝️ 1
Tomaz Bracic 2021-06-17T11:07:56.335500Z

uf... there is a lot written on this

Tomaz Bracic 2021-06-17T11:08:09.335700Z

the feeling around how the whole developoment is going on

Tomaz Bracic 2021-06-17T11:09:34.335900Z

Evan (author) ... has Elm ... at least this is the feeling... like a private / closed project put out to public for use. So when you read about complaints... (but then there is another side... who is really happy) it is really hard for some changes to happen. It is not really up for discussion

borkdude 2021-06-17T11:09:38.336100Z

I'm sure there are starter templates for reagent apps, etc

Tomaz Bracic 2021-06-17T11:09:45.336300Z

how the future will be ... what will be supported or not

Tomaz Bracic 2021-06-17T11:10:03.336500Z

those decisions are done in really really closed group if not only in Evans head

borkdude 2021-06-17T11:10:04.336700Z

Perhaps you could look at https://luminusweb.com/ which is a full stack tutorial / template

borkdude 2021-06-17T11:12:15.338700Z

Clojure's development is pretty much managed the same way: a small group of people, lead by Rich Hickey, decide what's going into Clojure and what the roadmap is. The community can vote on issues, etc. But Clojure, being a Lisp, allows a lot of stuff to be done in user land so I don't perceive this as a problem (maybe even a feature), especially with the "promise" of non-breakage.

Tomaz Bracic 2021-06-17T11:12:19.338900Z

With Elm ... I saw the opportunity to have a toolset / environment that would allow me build the project and deploy it with confidence that there will probably not be any issues. And even more important... have this environment that would allow me ... to come back to the project after a year (for example) ... and change few things... and not break them. And that it would still work.

Tomaz Bracic 2021-06-17T11:12:37.339400Z

And this is a huge benefit for me as being a solo freelancer

borkdude 2021-06-17T11:14:02.340600Z

@tomaz.bracic You can have the same with CLJS but you will have to figure out the toolset you like in the beginning. But once you have something working, you can re-use this for years on end.

Tomaz Bracic 2021-06-17T11:14:37.341100Z

i guess this is true only if you keep the distance with NPM and js libraries / packages, rigth?

borkdude 2021-06-17T11:16:06.341500Z

yes, CLJS doesn't have any tricks to magically manage breakage from the JS ecosystem

borkdude 2021-06-17T11:16:36.342200Z

the policy in the app I've been working on was for a long time: don't use NPM, don't use JS libs, unless you really really have to ;)

💥 1
Tomaz Bracic 2021-06-17T11:17:35.343300Z

what would you say is "the go to" library in clojurescript for websockets? I was actually searching for something that would allow me to use Phoenix Channels with ease... but not sure.

Tomaz Bracic 2021-06-17T11:18:18.344Z

https://hexdocs.pm/phoenix/channels.html

borkdude 2021-06-17T11:18:20.344100Z

In the app I'm working on I just use direct JS interop. Browsers have support for websockets, why use a library?

borkdude 2021-06-17T11:19:24.344900Z

I think this is all the code that we have:

(defn websocket! []
  (let [ws (js/WebSocket. ws-url)]
    (set! (.-onopen ws) (fn [_] (reset! websocket-error-count 0)))
    (set! (.-onmessage ws) (fn [ev] (on-message ws (read-string (.-data ev)) sse-fallback)))
    (set! (.-onerror ws) (fn [_]
                           (swap! websocket-error-count inc)
                           (reconnect!)))))

Tomaz Bracic 2021-06-17T11:19:43.345400Z

by default... if you use phoenix templates... you get provided phoenix.js which is official js library. That handles all sorts of high level / abstract actions... towards channels i assume

borkdude 2021-06-17T11:20:00.346Z

ok, in that case, you could interop with that JS library

borkdude 2021-06-17T11:20:27.346300Z

just use it. no need for writing a CLJS wrapper library. Interop with the host ecosystem is a feature of Clojure.

Tomaz Bracic 2021-06-17T11:21:27.346900Z

aha... so without Sente or something like that?

borkdude 2021-06-17T11:22:27.348Z

sente is a library which probably does something similar to your phoenix stuff: it tries to make integration between server and client easier. but if your server is already managing websockets, and it also provides this phoenix.js thing, use that, don't use sente

Tomaz Bracic 2021-06-17T11:24:32.349600Z

and with all those new terms... Leiningen, Shadow-cljs.... for purely closurescript project , a newbie ... and all that ... what would you suggest? Reagent and Re-freame did promise a lot, when I was looking at that

Tomaz Bracic 2021-06-17T11:25:03.350100Z

what kind of "stack" would help me progress

borkdude 2021-06-17T11:25:10.350300Z

if you're only doing a CLJS project, no server side, then only shadow-cljs is what I would advise

Tomaz Bracic 2021-06-17T11:25:35.350500Z

yes, only CLJS

borkdude 2021-06-17T11:27:26.351700Z

Just check out https://github.com/reagent-project/reagent-template

borkdude 2021-06-17T11:27:31.352Z

and try to make it work.

Tomaz Bracic 2021-06-17T11:27:32.352100Z

One of the things I noticed... I must admit that I am really pleasantly surprised with the fact that you are so helpful

Tomaz Bracic 2021-06-17T11:27:38.352400Z

I really appreciate

Tomaz Bracic 2021-06-17T11:28:02.352900Z

this can be really important for people like me... checking this new world of Clojure(script)

Tomaz Bracic 2021-06-17T11:28:03.353100Z

thanks!

👍 8
1
simongray 2021-06-17T13:04:22.354700Z

Clojure the project is, but the Lispiness of Clojure the language makes extending it quite trivial and there is no such nonsense as found in Elm such as forbidding unsanctioned interop with the host platform - rather the opposite: interop is touted as a major strength of CLJS.

simongray 2021-06-17T13:06:58.355Z

@borkdude I believe @tomaz.bracic is talking about stuff like this: "Why I'm Leaving Elm | Hacker News" https://news.ycombinator.com/item?id=22821447

2021-06-17T16:15:56.368700Z

Hey guys, I've been watching many Clojure talks and I would really love to use Clojure, but I can't stand the bloody JVM. And so my first question is: how does CLJS compare to CL? I know it has differences, I read a bit about it, but I'd like to hear real-world experiences, rather than just theory. Of course it doesn't have Java interop, but I don't care. It's got JS interop, that sounds perfect for me. Seems to me CLJS is primarily used with Reagent/Reframe to build web apps, but do people use it to build non-web things much at all? Such as that GH repo contains the CLJS code whereas the NPM package just includes the compiled JS? Thanks in advance for any insights 🙏:skin-tone-3:

2021-06-18T13:58:06.420700Z

Hey @valtteri and @quoll, thanks for the feedback. I'm currently exploring GraalVM (it has both startup time and Docker image size sorted, which is really important to me) and babashka, which looks really amazing and quite what I was after. I suppose I'd be using both. I'll definitely come back to Clojurescript for frontend dev. And so finally I can switch to Clojure now, good times!

🎉 4
2021-06-18T19:05:04.423800Z

@jakub.stastny.pt_serv I also write system utils with cljs + quickjs. No access to nodejs ecosystem but really low memory.

2021-06-17T16:16:48.369900Z

If anyone's interested what's my beef with JVM: 1. The startup time is killing me, I code on a free AWS EC2 instance, so it's really not fast. I'm used to MRI Ruby/Node.js startup times and would be aiming for something like that. I know that you should keep the REPL running and load your file into it, i. e. using Emacs/Cider and that's all good, but that only works during the development. 2. Secondly, you cannot pack it into a small Docker image, since one has to include the whole JRE, which takes 175MB using the openjdk-11-jre-headless package.) 3. Stack traces. Anyway, matter of personal preferences I suppose.

borkdude 2021-06-17T16:25:36.370100Z

CL = Common Lisp? Or did you mean clojure?

borkdude 2021-06-17T16:28:10.370300Z

What do you develop, what kind of apps?

borkdude 2021-06-17T16:29:01.370500Z

The biggest difference between CLJS and Clojure is its host platform obviously. JS doesn't have threads, everything is callback-based, but in Clojure you can do true concurrency, blocking, etc.

borkdude 2021-06-17T16:29:50.370700Z

Also Clojure is more dynamic, because you always bring the compiler with you into your application, whereas with CLJS it's not available in your build (in the mainstream case).

borkdude 2021-06-17T16:30:37.370900Z

If startup time is killing you, then take a look at graalvm, which can compile your entire app into a single binary with instant startup time.

borkdude 2021-06-17T16:31:01.371100Z

For scripting (in the sense of bash build scripts) you can use babashka, which is a Clojure interpreter with instant startup. It's not a full replacement, but covers what you typically do when writing scripts around your main application.

Apple 2021-06-17T16:42:37.371400Z

Do development on a performant machine and deploy the production code to AWS. Or check the oracle cloud which offers free VM and the ARM ones are pretty good. 4cpu 24G ram. Slow JVM startup can be mitigated with 'reloadable' workflow and REPL. Check https://www.youtube.com/watch?v=gIoadGfm5T8, https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/, https://luminusweb.com/docs/repl.html Docker: someone reported 42MB here https://stackoverflow.com/questions/40958062/how-to-reduce-my-java-gradle-docker-image-size. Or do you consider graalvm https://www.graalvm.org/reference-manual/native-image/? (I have no production experience)

emccue 2021-06-17T16:43:53.371700Z

As far as the whole JRE thing goes - you can make a reduced JRE using the new module system stuff, so its not a huge blocker https://openjdk.java.net/jeps/282

emccue 2021-06-17T16:47:34.372Z

generally though, while some people do use clojurescript on the backend it is probably one of the least common uses of clojure

emccue 2021-06-17T16:48:53.372200Z

that being said, it works. idk what the standard is nowadays, but i remember this https://github.com/anmonteiro/lumo

2021-06-17T17:09:43.375800Z

@borkdude sorry, I meant CL = Clojure. I mostly develop system utilities (out of my work that is), so nothing long-running. Interesting about GraalVM, I didn't know I can do that! Single binary with instant startup time would definitely solve my pain points there, I'll check it out. Babashka also sounds cool 😎

2021-06-17T17:11:36.377400Z

@zengxh thanks, will take a look. 24GB RAM/4 CPU free? Not sure if I believe it :) I will check though. 42 MB Docker image would be great, I will check GraalVM then!

2021-06-17T17:12:53.378400Z

@emccue interesting, I wasn't aware of the module system either, cheers!

2021-06-17T17:14:26.380900Z

OK, so what seems to be the consensus is that very few people run Clojure (ClojureScript that is) on the server on one of the JS platforms such as Node.js, but rather everyone seems to prefer JVM (or GraalVM). I will check that out then. What you guys said about GraalVM does sound promising!

borkdude 2021-06-17T17:41:15.382500Z

There is also a #graalvm channel. Here is a small tutorial. https://github.com/borkdude/jayfu The talk about this project will come online soon.

👍 1
2021-06-17T17:51:46.383500Z

Cool @borkdude, I'm checking it out.

2021-06-17T18:27:35.388100Z

Hey all, js interop question here. I am trying to understand how to invoke a js function that looks like this.load.image('imagekey', 'assets/pics/imagename.png');in Clojurescript. For example, https://github.com/photonstorm/phaser3-examples/blob/master/public/src/textures/get%20pixels.js#L14-L17 from the http://phaser.io project. I’ve discovered http://clojurescriptmadeeasy.com/blog/how-to-use-this-in-cljs.html to get at this, but I’m still stumped on the rest. I’ve tried (.image (.load this) key path) as well as (.image (.-load this) key path) but to no avail. I am sure it’s something simple. Any ideas?

p-himik 2021-06-18T11:24:53.410300Z

Can't really tell what's going on. If you create a minimal reproducible example with the exact steps on how to build and run it, I could take a look.

2021-06-18T15:48:47.421900Z

Thanks. Yeah, I’ll try to do that and post it.

2021-06-20T18:10:56.452Z

Ok, figured it out and wanted to close the loop. Your example,

(let [load (.-load this)
      image (.bind (.-image load) load)]
  (image key path))
does indeed work. I think my mistake was var-quoting the calling function. js interop is definitely different than Java. Anyways, thanks for the help!

👍 1
valtteri 2021-06-17T18:31:57.388500Z

For system utils Babashka sounds like a perfect fit. However there’s nothing wrong going with Node & CLJS either. Especially if you’re already familiar with the Node & npm ecosystem. I’ve done a few Node projects with CLJS and deployed them to AWS Lambda.

quoll 2021-06-17T18:39:24.388700Z

Before Babashka I actually did a lot of tools using ClojureScript on node. I still use a few of them. I’ve had to wrap a few things (like I/O), but it’s a nice platform to use. And the cljs repl is easy to start up now GraalVM is nice, but I would prefer to use it for large projects only (which I’ve only just started doing), because the compile time is extremely frustrating.

p-himik 2021-06-17T18:44:56.388900Z

(.image (.-load this) key path) will work only if this.load.image does not need this (which is this.load for it). If it does need it, you will have to find the function first.

p-himik 2021-06-17T18:45:58.389100Z

(let [load (.-load this)
      image (.bind (.-image load) load)]
  (image key path))

🐝 1
lgessler 2021-06-17T19:14:13.391400Z

do I understand correctly that I should expect resolve to break when using advanced compilation? I would like to use resolve on symbols referring to clojurescript vars, e.g. (resolve '=), (resolve clojure.string/includes?) and it appears to work in my dev repl, but name mangling in advanced compilation will disrupt this, right?

thheller 2021-06-17T19:15:24.392100Z

given that it can only resolve symbols statically it'll be fine in advanced. unlike CLJ the use of resolve in CLJS is pretty limited

lgessler 2021-06-17T19:17:26.392900Z

ah, yes I see, it is expecting a symbol as input 😢 thanks, guess i'll have to find another way

thheller 2021-06-17T19:18:34.393700Z

FWIW any kind of dynamic lookup will break in :advanced, unless all the things you look up are ^:export'd

borkdude 2021-06-17T19:19:09.394100Z

maybe @lgessler can back up a bit and explain what problem he's trying to solve?

borkdude 2021-06-17T19:19:28.394500Z

chances are that resolve isn't the right answer

lgessler 2021-06-17T19:21:30.396400Z

the situation is that I have an AST describing a kind of query on entities, where one kind of AST node is a clojure function applied with args to that entity, e.g. ['= :my-entity-field "foo"] , which would result in the query interpreter executing (= (:my-entity-field entity) "foo")

lgessler 2021-06-17T19:22:00.396900Z

i want the AST to be trivially serializable which is why i'm not just putting the function in it directly

borkdude 2021-06-17T19:22:51.398Z

just use a hash-map of all the possible functions supported in your AST/DSL

👍 1
borkdude 2021-06-17T19:23:23.399100Z

unless you need a full blown interpreter, you could also look at https://github.com/borkdude/sci

lgessler 2021-06-17T19:23:56.400300Z

yeah, that's what I was thinking--set up a function registry mapping symbols to functions and populate it once by walking supported namespaces

borkdude 2021-06-17T19:24:02.400500Z

advanced compilation will cut out functions that might be needed by your interpreter, so you need to hold on to them by some way anyway

👍 1
lgessler 2021-06-17T19:24:24.400800Z

oh yeah good point

borkdude 2021-06-17T19:24:36.401Z

this is essentially what sci is also doing

thheller 2021-06-17T19:25:14.401400Z

FWIW I have a similar thing here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/remote/relay/simple_query.clj

🙂 1
thheller 2021-06-17T19:25:33.401600Z

just using a multi-method, works great and is easily extensible

lgessler 2021-06-17T19:31:30.402200Z

ooh that's very similar to what we have, except your code is much cleaner! thanks for mentioning it, good to know this design's been successfully used elsewhere 🙂

thheller 2021-06-17T19:34:44.402400Z

yeah, the serializable part was very important and things work great. could use symbols too but I didn't want to deal with quoting 😉

lgessler 2021-06-17T19:47:45.403600Z

my situation seems small enough that a handmade interpreter will probably do but i'll definitely keep sci in mind--could see this problem growing hairier. thanks @thheller and @borkdude 🙂

👍 1
lgessler 2021-06-17T19:48:14.403700Z

yeah heh keywords might make things a little more comfortable

raspasov 2021-06-17T21:38:53.404500Z

That’s a GOOD policy!

👍 1