This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-29
Channels
- # aws (3)
- # beginners (160)
- # boot (2)
- # bristol-clojurians (3)
- # cider (62)
- # cljs-dev (77)
- # cljsrn (15)
- # clojure (147)
- # clojure-brasil (10)
- # clojure-dusseldorf (2)
- # clojure-gamedev (1)
- # clojure-italy (128)
- # clojure-russia (1)
- # clojure-spec (19)
- # clojure-uk (34)
- # clojurescript (408)
- # code-reviews (2)
- # component (1)
- # core-async (56)
- # cursive (1)
- # datascript (1)
- # datomic (81)
- # emacs (11)
- # fulcro (39)
- # java (16)
- # jobs (3)
- # lein-figwheel (2)
- # leiningen (6)
- # lumo (89)
- # off-topic (11)
- # om (2)
- # om-next (1)
- # onyx (17)
- # parinfer (4)
- # pedestal (3)
- # perun (1)
- # quil (3)
- # re-frame (19)
- # reagent (8)
- # reitit (5)
- # remote-jobs (5)
- # shadow-cljs (145)
- # spacemacs (1)
- # sql (7)
- # test-check (15)
- # uncomplicate (1)
- # unrepl (122)
- # vim (2)
- # yada (4)
Is there a non-verbose way to get a submap with only a few keys out of many?
Like, going from a map with {:a "a"} for the entire alphabet to just the keys for the letters in "cup"?
Ha! nevermind. I found it. https://clojuredocs.org/clojure.core/select-keys
@achythlook There’s also https://clojuredocs.org/clojure.set/rename-keys which comes in handy on occasion.
@konanki.sivaram Not sure what you mean by "refresh" in that context. As for :exclusions
, you just put them in the map with :mvn/versions
.
@seancorfield I did, uncomplicate.neanderthal
gives me an error. But the same thing in lein/project.clj
does not give any error
Show your deps.edn
file and the error you get...
(the artifact name would be uncomplicate/neanderthal
-- not .
)
Hello, do you have a hint how I get a clojure source file parser? One which does not throw away formating (spacess, new-lines, etc)? I need to read a clj/cljs/cljc file in Clojure+Clojurescript, make some changes and save it again without destroying the formating. I could not find a library for this purpose. Or could I do this with some Clojure built-ins? Thank you!
recently I want to use nodejs to RPC request clj backend services, need some help please
@witek use something like https://github.com/xsc/rewrite-clj, there also a cljs fork https://github.com/rundis/rewrite-cljs
@witek AFAIK the downside is that they use their own reader, so it might not be 100% accurate, if you need highest fidelity you could use tools.reader
and jump through hoops to preserve whitespaces during reading, you can abuse cljs.tools.reader.reader-types/log-source*
for that. I’ve successfully done it here (at least for cljs):
https://github.com/darwin/plastic/blob/master/src/meld/meld/parser.cljs#L32
https://github.com/darwin/plastic/blob/master/src/meld/meld/tracker.cljs#L28
I agree, depends on use-case, I think using rewrite-clj should be first choice under normal circumstances
ah, here is some rationale: https://github.com/darwin/plastic/blob/master/src/meld/meld/core.cljs#L7-L43
I just finished reading the results of the 2018 survey. Should I be concerned that as I encourage our team to use more Clojure, that we are going to see it become marginalized in the next few years? Several of the negative comments indicated that could happen based on the community, docs, inaccessibility to newcomers, core direction, etc.
it’s important to keep in mind that the vast majority of people that filled out the survey did so without entering comments or with positive comments. The relatively small number of negative comments get an outsized amount of attention (imo). Which is not to say that there aren’t things to work on.
So, I hear a lot of gripes about docs. I tweeted that I’m willing to help, but no one has taken me up on the offer. So, I’ll ask again: is anyone here working on a Clojure project that would feed me the bits and pieces to help flesh out the docs?
if you want to help out on the Clojure web site, see https://github.com/clojure/clojure-site/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22
How difficult/complex is the process for review and approval?
I’m pretty sure that although I can get started with something, it will take several revisions to make sure it’s accurate and useful.
just a matter of filing a PR which I’ll review
it’s ok if that takes a few rounds
great!
I might dive into some features I’ve not used, so it might take a few more rounds than normal. But that should produce docs better for the beginning experience, I’d think.
@jmckitrick That's awesome. Ping me if you need another set of eyes on some of those drafts.
Will do.
The first I’m looking at is here: https://github.com/clojure/clojure-site/issues/120
But I see that there have been docs added here: https://clojure.org/guides/weird_characters#tagged_literals
So just to clarify, is there more to be done?
prob better to have this discussion on the issue, but that is just an example of syntax, would be better to document #inst and #uuid in particular elsewhere as they are provided in core. #inst has a wide variety of formatting options as well.
should be under /reference somewhere
prob in the region of https://clojure.org/reference/reader#tagged_literals
changelog docs are at https://github.com/clojure/clojure/blob/master/changes.md#211-instant-literals
that’s good starting text
beyond that, the code is probably the next best place for information
@jmckitrick super power: write up what you actually ended up doing in the process of getting a new doc live, and publish that far and wide. let’s show folks how hard this isn’t
Good suggestion!
@jmckitrick Having done it for the REPL guide recently, I can testify that the contribution process was pretty smooth, even though that was a big change to the documentation.
It really irritates me how beautiful the docs are for some languages, and how such a great language as Clojure has everyone so busy coding, no one is writing docs to keep up.
No-one is an overstatement, there are some wonderful clojure docs, by @alexmiller and others, but more is obviously better!
re updating the docs, see (or update!): https://clojure.org/community/contributing_site https://clojure.org/community/editing
@pesterhazy more is not obviously better
One way people get to “more” is by embedding narratives everywhere they might be needed, rather than linking
another way people get to “more” is incrementally addressing singular complaints rather than stepping back and re-organizing
in those two cases more is not better
Hi, is it possible to create a library that has both clojure code and clojurescript code + a external javascript dependency?
@alexmiller @john Do I ‘assign’ you guys, request your review, or something else?
I’ll see a notification for any pr you create, but also feel free to explicitly request a review
Is there a tool to extract a list of environment variables that are being read from our code through calls to @weavejester's environ's env
function? Or maybe even a similar library that allows to specify a documentation string and default values and generates --help
output and possibly *roff / mandoc / CommonMark / MarkDown?
@jmckitrick you can just ping me here on slack and direct me to any docs you want me to review. You can assign to me in github as well, either way.
hmm, if I introduce a macro that requires another namespace as part of it’s output, is there a way to make sure the namespace that invokes my macro doesn’t also have to require the namespace?
(defmacro foo [args]
`(do (some.namespace/do-foo ...)
)
Wouldn’t this require some.namespace to be required in the call site?or would my macro have to dynamically require the some.namespace
as part of its output?
Can I somehow declare a dependency on a non clj(s) file? My use case is that I have a macro and it slurps a file and sets a var. If the file is updated the macros are naturally not recompiled. Can I somehow make that happen? I know I could by using a clj file instead of a normal file but that feels yucky for config. If possible I’d gladly use an edn file.
Don't know the answer to that,but I wanted to raise a warning because this usage is now discouraged in cljs. Macro could be cached (are not atm, only core is)
Actually sorry for the off-topic 😄
@jmckitrick nice work on the data literals docs! That's definitely going to be helpful for new folks.
Usually not a good idea but can extend to clojure.lang.IPersistentMap
right - generally it’s best to scope any protocol extensions as narrowly as possible, preferably only to concrete types
why not a good idea @alexmiller?
because IPersistentMap is a very generic interface which applies to all maps and record types
ok but you're not saying that extending a protocol to an interface is a bad idea then right?
so you are likely to create a situation where you conflict with other extensions and create ambiguity
there is nothing wrong with extending a protocol to an interface
my “Usually not a good idea” is in particular targeted at “extend a protocol for hash maps”
I am aware :)
Rich and I are at odds on that one
well, agreed :)
I got a question; I have an array of integers I want to convert to a byte[] of the ints equivalent hexes
So from [60, 129...] I want to go to [3c, 81...]
but not as Clojure's PersistentVector, as a Java byte array
got it, nm
I wrote a blog post trying to advocate for it's use, and it seems almost like it was a wrong course of action
I love this post. Super concise without being terse. Great examples. Attractive layout. Did you get criticism from folks? I don’t see a comments section.
@U0670BDCH I remember this article, what bad feedback did you get?
@U0670BDCH the one bit of feedback I have (that showed up on reddit a bit) is that lisps and Clojure are kindof jacks of all trades. They can do all these things, but they're not the best at any of them
except concurrency, Clojure is really good at that
core.logic is good, but not an amazing logic programming language
@U0670BDCH nice one
@U8ES68TGX I have no comments section, so I kind of rely on reddit post comment sections. I'm trying to keep the blog posts minimal. Maybe I should start linking the reddit comment section in the blog posts?
I agree with @U07TDTQNL, lisps have the advantage and disadvantage of being expressive
@john Interesting site! I'm going to try and get a few more blog posts out before I consider it a clojure reference, i'm hoping to pump out some more posts soon
Question: I came across a stackoveflow post yesterday asking why recur
wasn't working but standard recursion was. Turned out the problem was that recur doesn't gather rest args into a seq... which is documented behavior and highlighted in the clojuredocs sample below:
`; Note that recur can be surprising when using variadic functions.
(defn foo [& args]
(let [[x & more] args]
(prn x)
(if more (recur more) nil)))
(defn bar [& args]
(let [[x & more] args]
(prn x)
(if more (bar more) nil)))
; The key thing to note here is that foo and bar are identical, except
; that foo uses recur and bar uses "normal" recursion. And yet...
user=> (foo :a :b :c)
:a
:b
:c
nil
user=> (bar :a :b :c)
:a
(:b :c)
nil
; The difference arises because recur does not gather variadic/rest args
; into a seq.`
So - I've never had an issue with this before, probably because I only use recur
in conjunction with loop
, so any gathering of rest args would occur in context of a loop binding
It's a total non-issue to me, but it got me wondering why there would be a difference in semantics. I found plenty of material discussing the difference, but not the why. Would anybody be able to shed some light on this?
it is mostly because the code that supports var args and the code that compiles loop/recurs don't know anything about each other
when you compile a function the varargs support sort of lives outside outside of the function, so by the time the function body begins executing it is passed a collection, an the recur point (basically a jump target) is at the start of the function body
you dont need to “call” a macro from in a macro, right? if you emit the macro it will get immediately unrolled right?
i.e (defmacro foo [] ...)
if I just emit this
(defmacro bar [] `(do (foo ...))
then I don’t have to even escape it, right?
`(do ~(foo …))`
they are gathered in some machinery in clojure.lang.AFn between the call site and before the actually function body starts executing
i've never really encountered a problem with this before, it just caught me by surprise when reading the docs
but recur being a jump back to the top of the function body doesn't pass through that machinery
is it fair to say it's more like going to the top of the body as opposed to re-passing arguments
you just re-bind vars locally at the very beginning of the body, but never call it again
not text, data