Fork me on GitHub
#clojurescript
<
2022-09-01
>
zimablue01:09:27

does clojurescript have any equivalent to sayid's ability to trace all fns in a namespace? https://github.com/clojure-emacs/sayid

Lukas Domagala08:09:49

There's omni-trace, although it's not as finished as sayid

👍 1
jpmonettas16:09:09

@U63D7UXJB you can also take a look at https://github.com/jpmonettas/flow-storm-debugger/ . Current stable version (2.3.141) doesn't support entire namespace tracing (you need to manually trace each fn) for ClojureScript, only for Clojure, but next 3.0 hopefully will when it is ready

Lukas Domagala18:09:27

BTW @U0739PUFQ I don't really have the time right now, but we probably should see if we can combine efforts since our tools do very similar things

jpmonettas18:09:38

yeah it would be great!

jpmonettas18:09:54

let me know if you have any ideas on how

spacebat07:09:24

Am I missing something here? In the spirit of printf debugging, I want to stringify the type of a value, but it was not trivial: myapp.core> (type :foo) cljs.core/Keyword myapp.core> (str (type :foo)) "function (ns,name,fqn,_hash){\nthis.ns = ns;\nthis.name = name;\nthis.fqn = fqn;\nthis._hash = _hash;\nthis.cljs$lang$protocol_mask$partition0$ = 2153775105;\nthis.cljs$lang$protocol_mask$partition1$ = 4096;\n}" myapp.core> (clojure.string/trim (with-out-str (cljs.pprint/pprint (type :foo)))) "cljs.core/Keyword"

thheller07:09:48

(pr-str (type :foo))

spacebat08:09:06

thanks that's good to know

Roman Liutikov08:09:32

The following is true for both Clojure and ClojureScript. Is that intentional? I'd expect the second a argument to shadow the one destructured from a map.

(defn f [{:keys [a]} a] a)

(f {:a 1} 2) ;; 1

😅 1
p-himik08:09:41

Destructuring is done as the first step in the body of the resulting function.

p-himik08:09:20

user=> (macroexpand-1 '(fn [{:keys [a]} a]))
(fn* ([p__138 a] (clojure.core/let [{:keys [a]} p__138])))

Roman Liutikov08:09:48

Is there a ticket or a discussion for this behaviour? I'm pretty sure it was discovered before many times

p-himik08:09:23

FWIW, first time I hear about it. :) And a quick search doesn't show anything.

p-himik08:09:00

Also, while I'm not a language maintainer, I strongly suspect that this behavior will never be changed. Because such a change could break some already existing code.

Roman Liutikov08:09:05

that's true and super unfortunate

thheller09:09:04

there was a discussion before and I think the conclusion was that clj-kondo could cover that? maybe it already does

👍 1
Mitja13:09:06

I don't think it does, at least the version I'm using marks the first a as unused

quoll14:09:24

The discussion wasn’t too long ago, and yes, I think it was a question as to whether clj-kondo should look for it. I was a bit surprised to see how it worked, but shouldn’t have been, given that destructuring is performed via macros.

Justin13:09:03

Hi, just starting out and I'm unsure how to work with my filesystem. The options I've found are: • fs (nodejs package) • goog.fs I'm having a bit of a hard time understanding how to use goog.fs! I've used the Nodejs fs package and understand it but is it more typical to work with the goog libs?

p-himik13:09:59

From the docstring of goog.fs: > Wrappers for the HTML5 File API So it's not what you need.

zimablue13:09:20

I use the promises API in the nodejs fs module, then one can use <p! or some more advanced cljs promise interop and feels more clojure-ey IMO, then also write little wrappers for the underlying fns basically applying (clj->js) to contain the raw javascript arguments

zimablue13:09:47

on input and output

Justin13:09:51

Thx to both of you!

quoll14:09:50

Personally, I’ve always liked the synchronous API on NodeJS.fs, because then I can make my Clojure and ClojureScript almost identical

zimablue14:09:56

i get you but all the guidance on node ever is never to block in prod, it probably doesn't matter a lot of the time but it feels very dirty

Justin15:09:27

@U63D7UXJB Just so I'm going down the right path, is it the

fs/promises
library you are referring to? This is the one I typically use in JS