This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # bangalore-clj (3)
- # beginners (23)
- # boot (89)
- # cider (11)
- # cljs-dev (22)
- # cljsjs (5)
- # cljsrn (21)
- # clojure (141)
- # clojure-android (1)
- # clojure-berlin (1)
- # clojure-greece (1)
- # clojure-italy (13)
- # clojure-mke (2)
- # clojure-nl (8)
- # clojure-norway (5)
- # clojure-russia (22)
- # clojure-sg (4)
- # clojure-spec (38)
- # clojure-uk (109)
- # clojurescript (150)
- # consulting (4)
- # core-async (7)
- # cursive (13)
- # datascript (8)
- # datomic (72)
- # dirac (185)
- # emacs (5)
- # figwheel (2)
- # flambo (1)
- # hoplon (13)
- # immutant (6)
- # lambdaisland (7)
- # lumo (46)
- # off-topic (13)
- # om (4)
- # onyx (1)
- # pedestal (1)
- # re-frame (68)
- # reagent (15)
- # rum (16)
- # slack-help (4)
- # spacemacs (22)
- # specter (3)
- # vim (10)
- # yada (28)
@piotrek in SO pointed out that I should be able to extend ring.core.protocols/StreamableResponseBody to do this
(extend-protocol protocols/StreamableResponseBody LinkedBlockingQueue (write-body-to-stream [output-queue _ ^OutputStream output-stream] (log/error "starting") (with-open [out (io/writer output-stream)] (.write out "starting") (loop [chunk (.take output-queue)] (log/errorf "got chunk %s" chunk) (when-not (= chunk ::EOF) (.write out (str chunk)) (.flush out) (recur (.take output-queue)))))))
and setting the jetty output buffer size to one does make it "work" though that's a bad idea for other reasons i suppose
Reloading protocols in the REPL does have some caveats I believe. Not sure if that affects records only or existing class extensions as well.
I don't normally need to reload the library that uses a protocol to have it notice that I extended that protocol right?
It does seem to work when all the protocol is extended in a namespace that's loaded initially, so this is a REPL only situation whatever it is that's going on here
can anyone point me to a good article explaining the viewpoint of not using namespace aliases?
@wei of not using them? I'm not sure that I've seen any. What problems are you anticipating?
@tbaldridge the arguments I’ve heard for using fully-qualified names for every function call are related to readability. interested to see the argument fleshed out in an article and I was wondering if anyone has written about it
I’ve been preferring one-letter namespace aliases for conciseness, so I’m interested in hearing the opposite view
then, when I import the namesapce, it's just [c.g] and its' short enough to not need to alias
qqq: that sounds horrible. Now I never have a clue what the namesapce I'm in is doing.
That saves like what...10 characters? What's the use-case that makes that a good tradeoff
use last part of namespace as aliasename , example: (:require [http://aa.bb.cc :as cc] [xx.yy.core :as yy])
is it possible to refer to a gensym generated with the
# syntax from inside
got it. It’s just that I end up using gensym “manually” most of the time and I thought that maybe there was a way to avoid it that I didn’t know about
@ctford Hi there. I’m hoping you could help me understand something with Leipzig (which I order by the way), I’m passing in nils to act as breaks in phrases, but when I use live/play it silently fails and stops playing entirely when it gets to the nil. Is this behaviour you’ve experienced before?
@wei, I haven't heard convincing arguments to not use namespace aliases. Most programs will have a convention to them that makes their aliases make sense in the context of the project. As a consultant I read a lot of code written by other people, and the aliasing of namespaces has never been a problem for readability. Problems with readability I've encountered are much more around things like overuse of higher order functions, macros, etc.
if I call a function from within a core.async go block and then try to use the
<! channel macros within that function it is considered "not in go(....) block". What's the rationale here?
answering myself. Found a discussion around go block semantics at https://github.com/clojure/core.async/wiki/Go-Block-Best-Practices
timeout returns the same object, for two different calls, I know it's memory efficient, but it's not the Clojure idiomatic way I guess
is there a version of
with-out-str that returns both the stdout string and the value that would have been returned from the expression?
I want to basically do
(let [[elapsed result] (with-out-str (time (some-function)))] (log elapsed) result)
@tjtolton I don't think there's anything like that in core, but if you check out the source, it's a really simple modification
I'm not asking because I disagree, I'm asking because that's valuable information to have
is the poison pill pattern considered an anti-pattern for core async pipelines? i.e. sending down a special value down a chain of pipelines to shut the "network" down
i wouldn't say it's an anti-pattern at all, but usually you close the channel instead of poisoning it
You'd use a different poison pill if you want to keep the channels open after poisoning
does anyone have any conventions around using
some?? I can’t think of when I’d ever use it over just checking the truthiness of the form instead, or using
empty? in the case of sequences
I'm seeing a weird stackoverflow occur and I'm having a really hard time reasoning about it
I have no idea why this is overflowing. My understanding is that this should be tail call optimized, so this sort of overflow shouldn't happen right?
concat in a loop: https://stuartsierra.com/2015/04/26/clojure-donts-concat
link-snapshot is either
(get-as-hickory ...) or its an error. But either way you call
(data-parser-fn link-snapshot) on it. Is it possible you fail above and then call
data-parser-fn on data that doesn't make sense?
i think the reasoning is that
cond is more like an
if .. else if ... else if .... where
case is more like a switch
I see; it just surprised me as I'm used tocase throwing xceptions (which I then debug) on not matching, whereas cond just "silently return snil"
case is the exception here, most things return
nil in clojure on not found/no match
if so, I bet data-parser-fn is doing something funky with nested lazy operations in a loop
hello. I’ve just used https://github.com/clojure/core.match in my re-frame pet project and it adds some clarity to my code. I wonder why it’s stuck at alpha version?
Well, to quote some maintainers of Clojure: " Because we don't really associate any emotional significance to the version number." 🙂
wellllll, the whole spec.alpha seems to telegraph feelings about the significance of the alpha designator, if not the version number
But last I heard (and I can't find the talk) there's also some open questions about how core.match should evolve in a language like Clojure that prefers open dispatch.
I.e. in a perfect world we could extend a match statement with new clauses from a different namespace, and yet not loose any of the performance or features of the original statement.
there’s also the fact between for, doseq, match, and core.async you can use two, maybe three if you are lucky, in one nested scope, before your methods are too large for the jvm
sometimes you can only get away with one, depending on how well the code is factored…
doseq is a neat nerdsnipe https://gist.github.com/ghadishayban/fe84eb8db78f23be68e20addf467c4d4 even with the neat approach there you still generate a fair bit of code
heh that code output doesn't even take into account chunked seq or the let/while/when clauses
yeah, it is a rabbit hole, which makes it a neat puzzle, you think "oh this is simple, I'll just ..." and then five hours later you have something that frustratingly still doesn't cover all the edge cases
the compiler nerd side of me hates that Clojure isn't as simple as Scheme. Every other side of me is thankful that it's not.
It'd be a fun project, but remember, CLJS doesn't have threads, Vars, namespaces, type hints (the list goes on).
I sat down recently and thought about what CLJS on the JVM would look like and it's a nasty mess of circular deps.
cljs gets away with alot just by virtue of having to compile to js rather than to bytecode
i keep starting mini projects to self-host and bootstrap clojure but I always end up drowning in complexity, pulled between the ideal implementation that I'd like to build and the reality of compromises that need to be made in order to bootstrap
have you looked at shen's klambda? I haven't really, but I understand that it is like the IR for shen, so you can bootstrap shen on a new host by writing a klambda interpreter, and it must have some facilities for host interop and people have used it to bring up shen on a bunch of hosts
@U46LFMYTD not sure what kind of visualization you mean, but for the basic stuff,
cider-inspect is quite good
@U06BE1L6T cider-inspect is great, but I'm really looking for a charting library to create, say, boxplots or histograms etc...
@darwin Its a good suggestion. When I was using Atom as my editor I was using proto-repl combined with this proto-repl-charts. Since switching over to Emacs and Cider I was not able to get proto-repl-charts to place nicely.
Sorry, first time slack user. Is it better to reply in the thread or in the main channel?
So far I'm aware of the following ideas. Incanter uses Jfreechart, which I find creates very old fashioned looking plots, but its good you can use it from a repl. Proto-repl-charts is using C3.js as a backend, built on top of D3.js which is cool which creates plots in a browser window. Similarly gorilla-repl plots using a similar endeavour called vega,
i’ve used gorilla-repl a bunch (http://viewer.gorilla-repl.org/view.html?source=github&user=wiseman&repo=leaflet-gorilla&path=example-worksheet.cljw is one of the more involved examples, with a map renderer i wrote), but i would probably look to see what the state of jupyter/clojure integration was if i were doing that again.
it’s a logging library, so I imagine it’s pronounced “timber”, as someone would yell when chopping down a tree; in the logging industry.
timbre and timber are completely different. lumberjacks have timber, musical instruments have timbre ("TAM-br").
assuming it was intentional, it's a beautiful pun. different logging libs have different timbres, even tho they all log.
I have a question about excluding dependencies when pushing to clojars. When I'm working on some code, I tend to have more "development dependencies" in my project.clj file than are needed for users when I push to clojars. For example I might have some testing dependencies or some visualization dependencies that I use when I'm writing and testing the code, but these do not need to be in the jar that I distribute. Is there a flag to list some dependencies as development, so that lein deploy clojars does not add these as dependencies for others?