Fork me on GitHub
#beginners
<
2019-12-14
>
samcferrell04:12:42

I like the aesthetic of (comment " ... "), any reason I should use ;; instead?

kevin.van.rooijen09:12:01

You can also use #_ , which works as ;; for an entire expression. For example, these two are the same:

#_(def inc2
    (comp inc
          inc))

;; (def inc2
;;   (comp inc
;;         inc))

kevin.van.rooijen09:12:38

Oh I just realized it was already mentioned below 🙂

andy.fingerhut04:12:42

(comment ...) evaluates to nil , which is not correct in some places within your code.

user=> (if (= 2 2) :true :false)
:true
user=> (if (= 2 2) :true (comment "next line is false") :false)
Syntax error compiling if at (REPL:1:1).
Too many arguments to if

samcferrell04:12:53

mmm thats a good reason

hindol.adhya05:12:34

When should one use a promise-chan?

seancorfield05:12:21

@samcferrell I only use (comment ,,,) for dev-only code that I want in files -- "Rich Comment Forms".

seancorfield05:12:39

For actual comments, I use ;; for full line comments and ; for end-of-line comments.

seancorfield05:12:21

If I want to "comment out" a form in my code, I use #_ which makes the form completely disappear (not evaluate to nil, which is what comment does).

seancorfield05:12:42

@hindol.adhya No idea. Maybe ask in #core-async since that seems a bit esoteric for #beginners ?

shaun-mahood05:12:37

@samcferrell I think the semi-colon comments are the only ones that are completely skipped by the reader - so if you have something like a :ns/ or other unreadable forms it will keep them from causing problems

seancorfield05:12:49

Right, both (comment ,,,) and #_ expect a readable form/set of forms so what's inside comment and what follows #_ must be valid Clojure code.

slack.jcpsantiago08:12:19

I'm trying to use this function from the twitter-api library https://github.com/adamwynne/twitter-api/blob/master/src/twitter/api/restful.clj#L163 but loading it

(ns mylib.twitter
  (:require
    [twitter.api.restful :as twitter]))

(api/media-upload-chunked my-creds :params {:media image})
results in java.lang.RuntimeException: No such var: twitter/media-upload-chunked what am I missing here? isn't that function available externally?

andy.fingerhut08:12:57

Have you tried doing this at a REPL, and if so, do you get the same error messages?

user=> (require '[twitter.api.restful :as t])
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.

slack.jcpsantiago08:12:09

@andy.fingerhut if you mean the SLF4J messages, yes I do get them

andy.fingerhut08:12:11

The name media-upload-chunked appears not to exist anywhere in the 1.8.0 JAR file released on Clojars

andy.fingerhut08:12:43

Probably the source code you are seeing on Github is more recent than the released version

andy.fingerhut08:12:14

According to this page about the package on http://clojars.org, version 1.8.0 of that library was released in Feb 2017: https://clojars.org/twitter-api

slack.jcpsantiago08:12:42

ah you are right! there is even an issue about it. So that means there is nothing in the code that prevents me from importing that function (if it existed in the clojars version)

andy.fingerhut08:12:34

You can also create your own JAR file locally on your dev machine from any version of the Github source code, if you wish.

slack.jcpsantiago08:12:23

thanks! I'll look into that

alex.sheluchin11:12:14

I'm trying to use https://github.com/crisptrutski/matchbox, which expects keywords corresponding to keys in the Firebase tree. So a foo key in the tree would be accessed with :foo, like:

(m/listen-children
  root [:foo]
  (fn [[event-type data]] (prn data)))
My issue is that the keys in my Firebase tree are sometimes prefixed with a colon, like :42. When I try to look those up using :42 in the code, it doesn't work, and using two colons doesn't work because then Clojure auto-resolves the keyword to the current namespace. How do I get around this?

pithyless17:12:22

@ You can try to get around it via clojure.core/keyword:

((keyword ":42") {(keyword ":42") :ok})
;; => :ok

alex.sheluchin18:12:10

@ perfect, thanks!

sarunas091914:12:26

Hello guys, can you recommend some tutorial projects in GitHub to get practical experience in Clojure (and JVM in general) concurrency? I've read theory from various resources. I am with Erlang background (3 years of commercial experience) so it would be very interesting to compare concurrency aspects from practical side, not just theoretical. Thanks!

peder.august20:12:38

Any tip on a websocket library, both cljs and clj for a complete beginner to websockets, especially in clojure

dpsutton20:12:21

There’s sente

hindol.adhya20:12:42

@peder.august Server or client?

peder.august20:12:04

@hindol.adhya both, two separate libraries is ok

peder.august21:12:26

@dpsutton I tried it out, but couldn’t wrap my head around it

hindol.adhya11:12:46

I couldn't wrap my head around sente either. Did you take a look at http-kit?

peder.august16:12:39

I did take look at it now, and it seems to introduce the concepts with a bit more simplicity. I’ll try it out. Already converted my server to use it.