Fork me on GitHub
#clojure
<
2019-01-27
>
lilactown00:01:18

is it possible to tell clojure.walk/postwalk not to descend into maps, only vectors?

andy.fingerhut00:01:10

Not that I can think of. You can copy and modify the source of clojure.walk/walk pretty easily, if you want.

Jan K00:01:00

Or use tree-seq, that one gives more flexibility https://clojuredocs.org/clojure.core/tree-seq

lilactown00:01:03

I think I’ll just call my function recursively and hope that no one passes me a huge vector ¯\(ツ)

lilactown00:01:56

oh, that’s pretty much what clojure.walk does anyway

lilactown00:01:06

I thought it had something fancy that was preventing the stack from growing

andy.fingerhut02:01:54

clojure.walk/walk should work for arbitrarily large collections without blowing the stack. It should only grow the stack when there is more nesting in the collection given.

lilactown05:01:46

i’m walking a hiccup-like structure, e.g.:

[:server/http {:port 8000 :join? false}
           [:router
            [:db/conn [:config]]]
           [:foo
            [:db/conn [:config]]]]

andy.fingerhut06:01:59

Maybe not all, but most code that deals with nested structures - reading, printing, processing - will typically cause a number of levels of function calls that is proportional to the level of nesting of the data. 20 levels deep of nesting isn't going to blow the Java call stack. 1000 probably won't either. If you've got 20,000 levels of nesting in your data, you will probably start blowing at least the default Java stack depth limits.

andy.fingerhut06:01:04

I am not aware of any reasons to have such deep nesting of data, except for artificially generated test cases that attempt to determine where the call stack depth limit is.

witek14:01:55

How do I return an error code from my foo.bar/-main function, when starting it using clojure -m foo.bar? Just returning the error code does not work. Program always terminates with error code 0.

borkdude14:01:00

(System/exit 127)

lilactown18:01:24

I have a devtool that I want to allow people to easily install into their Clojure projects

lilactown18:01:35

atm, it relies on websockets to communicate with a web UI

lilactown18:01:36

I’m worried that installing the dependencies for and starting a webserver on behalf of a user is really invasive

orestis20:01:33

@lilactown no other way around it, I guess. Unless you expose the WebSocket API as a core.async channel and allow people to override the WebSocket implementation with their own server.

hiredman20:01:03

I mean, surely it is isn't a huge stretch to go from websockets to just sockets?

hiredman20:01:47

and that is just part of the jre

dominicm20:01:49

Figwheel does it :)

lilactown20:01:54

hmm, well a browser page can’t talk just sockets

lilactown20:01:59

most people don’t run figwheel in the same process as their server-side app

dominicm20:01:00

I've always seen it done that way fwiw, at least in dev.

lilactown20:01:45

really? that seems strange. I guess I haven’t used figwheel in awhile, so maybe I’m missing some context

dominicm20:01:56

However, I have wished that figwheel could be used without its server, so a callback based API would be wonderful.

dominicm20:01:15

All our projects at work, and also Edge work that way.

dominicm20:01:04

Most people won't mind you starting a Web server, and you can separate the API so it is easy to upgrade.

lilactown20:01:34

what do you mean by callback-based?

dominicm22:01:26

Your java thread will run a callback which will write to whatever transport I use (websocket, sse, core.async, long polling, whatever). Same thing on the frontend for responding to messages that come in

lilactown20:01:50

I think it would be nice, if the user already has a webserver running, to provide a way to serve the devtool through that instead of starting it’s own server

lilactown20:01:58

but i’m not sure how to do that generally

Lennart Buit20:01:04

how would it know that that is the case?

Lennart Buit21:01:35

I guess you would want to mount your dev tool into the running webserver. That would mean having a companion lib per “possible webserver” plus one for apps that don’t have any

Lennart Buit21:01:50

Like, my-dev-tool-pedestal

phill21:01:51

I like to run a web app with its own, you know, lein repl thing, and start lein figwheel in another terminal; so the l.f. terminal listens to port 3349 and the l.r. terminal listens to port 8088 or whatever the website is. Amazingly it hangs together. The js made by figwheel apparently has the 3349 baked in, and learns dynamically the origin of the page that embedded it (ie 8088)

phill21:01:16

Is this the appropriate forum to ask about VS Code? Or maybe Calva, I don't know whose fault it is. When the point is adjacent to a paren or bracket or brace, the point is invisible. The two brackets are outlined and the point is apparently blended in with one edge of one bracket. Hard to guess which.

phill22:01:55

Aha, editor.cursorWidth. Changing it from 0 to 4 makes it easy enough to see.

phill21:01:52

Is cursor obviousness configurable?

lilactown21:01:27

@phill try #calva-dev