Fork me on GitHub
Ziad Salah12:11:32

Hi all, just recently found out about Portal and have been really enjoying exploring it.

Ziad Salah12:11:11

I have a potentially silly question to ask. Let's say that I have a particularly tricky bit of code I'm trying to understand and debug that has several layers of function calls and deeply nested data structures. So I grab portal, add it as a dev dependency to the project, and start adding a bunch of tap> calls around my production code. When I'm done for the day, would it be okay for me to commit the added tap> calls (as in, is their presence in production code harmless?), or should I make sure that that never makes it into production code? I suppose I'm just curious what people's workflow looks like. Do you have a local changeset that you keep your added taps in to avoid accidentally committing it? etc.. Any insight here would be wonderful.

Ziad Salah12:11:16

I'm partly considering how working with other team mates might look like as well. Would you share a patch with them? or some other alternative?


I use taps like these mostly for debug, so I don't commit them, otherwise it will get noisy

👍 1
R.A. Porter12:11:40

Leaving taps in production code is mostly harmless (about as expensive as a logger checking current levels), but as a rule I leave very few of them in, just those that would be useful for run-time analysis of the system with an attached REPL.


I use (defonce tap! #(when nil (tap> %) %)) and just toggle nil to true when working locally


That's under a toolbox namespace


We tend to remove the calls when we're done debugging but sometimes we've left them in and committed them and they've gone to production - and that's harmless. There's virtually zero overhead calling tap> and we have no listeners enabled in production. In other words, I wouldn't worry about it too much.

Ziad Salah09:11:27

Thank you all for your input :)

Ben Sless10:11:53

I wish taps by default returned their tapped value and injected location metadata. Add to that perhaps a clojure option to turn them off globally. A macro tap can be compiled to a true noop in production


@UK0810AQ2 I believe there are plans for a tap-> in Clojure 1.11


that would be great, I miss that a lot too


(-> expr (stuff) (more-stuff) (doto tap>) (yet-more :stuff)) 🙂

💯 1
Ben Sless14:11:33

It's a convenience, but it would be welcome


@U04V70XH6 I like that pattern, gonna use it 🙂


I was creating a live template to get it quicker, than I realize I had this Live template (snippet) already, just forgot it 😅