Fork me on GitHub
#beginners
<
2016-09-11
>
eslachance04:09:44

Alright imma say it: core.async is freaking sexy. I'm in love.

; define an async channel
(def log-chan (chan))

; start a process thread and wait for events on that channel
(thread
 (loop []
  (when-let [v (<!! log-chan)]
    (prinln v)
    (recur)))
 (prinln "Log Closed"))

; Define a function that adds events to the channel
(defn log [msg]
  (>!! log-chan msg))

; Call a log file
(log "foo")

eslachance05:09:50

I am well and proper getting nerdgasms here with this async video

shaun-mahood05:09:33

@eslachance: Lot’s more at https://www.youtube.com/playlist?list=PLhi8pL3xn1OTDGCyXnkZStox6yFjn2583 if you want to go further, though it does require a subscription (I find it worthwhile at that price though).

eslachance05:09:52

huh! I didn't even know youtube did that (the subs thing).

eslachance05:09:20

But yeah seriously that video from Timothy is just perfect, the kind of thing that gets me to learn and appreciate the language

eslachance05:09:24

I want more of that

shaun-mahood05:09:46

The rest of his stuff is equally good

eslachance05:09:57

Oh it is him lol

eslachance05:09:29

My friend @oahner keeps telling me about stuff in clojure and he always gets me really interested but then I look at the stuff and I get scared with complexity. Finally I'll be able to follow along XD

shaun-mahood05:09:41

Yeah, there’s so much interesting stuff that it’s pretty hard to know where to start. I found core.async and CSP super interesting when I first started but I’ve not found an actual use for it in my work, but the concepts from it (and many other things in Clojure) have completely changed how I think about things. It’s a pretty enjoyable journey and there’s always more to learn so I haven’t gotten bored yet.

eslachance05:09:50

I most definitely know what to use channels and stuff in. Unfortunately for some reason the code in the video doesn't work (probably because async changed) so I have to look into that

eslachance05:09:53

it was so elegant.. 😞

eslachance05:09:27

oh! nevermind I had to use async/chan instead of chan

credulous15:09:53

I’m missing something… probably obvious? in the (ns :require) syntax I think

credulous15:09:38

I just tried to move some functions into another ns… now I have src/cavalry-stats/core.clj and src/cavalry-stats/data.clj

credulous15:09:54

in data.clj, the ns decl is (ns cavalry-stats.data … In core.clj, when I type (require ‘cavalry-stats.data) it works fine

credulous15:09:17

Sorry, I mean when I type (require ‘cavalry-stats.data) and eval it

credulous15:09:43

But when I try

(ns cavalry-stats.core
   (:require [ring.adapter.jetty :as jetty]
             [compojure.core :as compojure]
             [ring.util.http-response :as response]
             [ring.middleware.reload :refer [wrap-reload]]
             [ring.middleware.format :refer [wrap-restful-format]]
             [selmer.parser :as selmer]
             [cavalry-stats.data :as data]
             ))

credulous15:09:03

I get an error, CompilerException java.lang.Exception: namespace 'cavalry-stats.data' not found, compiling:(cavalry_stats/core.clj:1:29)

madstap16:09:50

I don't know if this is what's causing your problem, but the folders and files in src should have underlines instead of hyphens. So the file src/cavalry_stats/core.clj should have the ns (ns cavalry-stats.core)