This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-03
Channels
- # admin-announcements (6)
- # announcements (1)
- # beginners (17)
- # boot (69)
- # bristol-clojurians (1)
- # cider (7)
- # cljs-dev (115)
- # clojure (76)
- # clojure-russia (12)
- # clojure-sg (2)
- # clojurescript (152)
- # core-async (2)
- # core-logic (7)
- # cursive (18)
- # datascript (4)
- # datomic (2)
- # hoplon (12)
- # ldnclj (26)
- # off-topic (1)
- # re-frame (48)
- # reagent (6)
Weird behavior in a Clojure 1.7 repl:
=> #=(list list)
()
Is this by design?I would expect to get back '(list)
clojure.tools.reader has the behavior I'd expect, but read-eval has significantly more functionality there anyway (resolving all sub-arguments instead of expecting symbols, etc.)
> (clojure.tools.reader/read-string "#=(list list)")
(#<clojure.lang.PersistentList$1@1acd8315>)
I don't know much about this area, but is it the same as the following?
user=> (eval (list 'list))
()
@nberger, I'm not an expert on the read-eval construct either, but I would interpret #=(...)
to generally be equivalent to (eval '(...))
in my repl (emacs cider with clojure 1.7), it behaves as expected (list list) gives a list with one element
@aengelberg The two behaviors you describe are perfectly consistent
Whereas typing #=(list list)
on the rEpl will cause it to read and then *E*val the string. So the reader returns (list)
and the repl evaluates that (which returns an empty list)
Clojure 1.8.0-alpha4 is available https://groups.google.com/d/msg/clojure/D9CZNGPKw-4/e1bo70grCQAJ
hmm, you seem to be correct. it's possible other changes have foiled that change or something. will re-open.
ragge: yeah, agreed
I went through the rest of the list and I believe all other reported tickets for 1.8 were applied (I did find one jira number typo though)
@athos thank you for catching it!
You're right @malabarba! I totally forgot that the REPL would be doing TWO passes, evalling the inner #=
form and then evalling the whole form as usual
Thanks!
👋 — any advice for debugging clojure.tools.namespace.repl/refresh
throwing an error because it cannot find a namespace in my project? the project compiles normally, and the namespace definitely exists in a non-weird location
@bcobb: does that ns have any gen-class stuff going on? my advice is to (require '[ns.name.goes.here :reload true])
in the repl to see if you can rule tools.namespace out
any user.clj
on the classpath always gets loaded before anything else due to RT.java's static initializer - so if your user.clj
needs some clojure stuff to run before it loads, you might need to restructure a bit
@trptcolin oh, good idea. grabbing food but will try that out after. thanks!
Is this ticket even possible to fix? It's been years ... http://dev.clojure.org/jira/browse/ASYNC-27
It would be so great if all of the line number info from the original code wasn't lost.
@trptcolin: tentatively saying that gen-class
was the culprit. had system-building code in a gen-class
ns, and extracting it to its own namespace so that the gen-class
ns is not a dependency of anything seems to have fixed my problems
i wish i could say i understand exactly what’s going on, but i now have something concrete to learn more about
@bcobb: yeah i've hit this before, had a hell of a time debugging, and ultimately now i don't name my repl-init ns user.clj
anymore
because otherwise my user.clj might require my gen-class ns, which requires some clj compilation, which requires RT.java to be loaded, which hits https://github.com/clojure/clojure/blob/d534894c3006474068e46b67e4b838bf3727722d/src/jvm/clojure/lang/RT.java#L460-L480, which loads user.clj
@bcobb 9/10 of the problems I hear about with tools.namespace are caused by AOT-compilation
I also use dev.clj
instead of user.clj
now as @trptcolin suggests.
quick question: say I have something like a “player” which needs to be referenced across the game; is it idiomatic to have something like
(def player (atom {:name "Joe" :health 100 :denarii 10 :loc "here" :inv []}))
(defn get-player [key]
(@player key))
(defn update-player [key val]
(swap! player assoc key val))
@stuartsierra: ah, good to know, thanks for chiming in
thanks for your help @trptcolin!
@benbailey: That's a global singleton, which is often convenient for small apps but quickly gets cumbersome when you have lots of them scattered across your app.
Yeah, I would imagine so. I guess I’m struggling of finding a functional way t o represent “actors” in the game.
I could always have one global state
with actors as children, but that doesn’t seem right
@benbailey: usually there is some data structure representing the "state" of your entire application. This state can be created and managed by the entry point (`main`) of your app. Individual functions are passed that state or pieces of that state as arguments.
You can still have mutable references (`ref`, atom
, agent
) — at whatever level you need in the structure for efficient updates.
update-in
/ assoc-in
are your friends there
You're welcome!
I am looking for clojure hosting solutions other than Digital Ocean
@lazy-lambda: hosting clojure on aws and heroku are pretty straightforward (especially aws elasticbeanstalk for webapps)
@noisesmith: Okay, I will check out AWS.
lazy-lambda: with a webapp you can use lein uberjar, and simply upload the result as your jar (with a few pretty simple gotchas)
@lazy-lambda: I started using http://tutum.co recently for clojure apps.
@podviaznikov: Are you using tutum in production ?
I’m using it now while building new app. Started using it few months ago (have approximately 20 containers deployed to 4 nodes). If I don’t see any problems - I’ll use it in production
@noisesmith: Example of the few pretty simple gotchas?
jeffmk: you can't count on a persistent disk, or customizable system - the beanstalk boxes are cookie-cutter and you'll be moved to a new one with no warning basically
good part - scaling is a cinch, hard part - developing an app that works within those constraints
so eg. all resources need to use io/resource and not io/file, no creating files that are not in /tmp/ basically
Is there any better way of structuring a project regarding which directories contain clj and cljs and cljx?
@pupeno: what's your pain with the directories structure? I guess you are using src/ and test/, but perhaps there's something specific to cljx? Is cljc an option?
Hello, this is a more of beginner question but I'm trying to understand how I should go about iterating over a sorted map and it's content, so for a given list of maps I perform a group-by with the intent of sorting over each group's key values to display the content my code so far:
(let [sorted-by-url (sort-by :uri [{:user-id 1 :uri "/"}
{:user-id 2 :uri "/foo"}
{:user-id 1 :uri "/7"}
{:user-id 1 :uri "/3"}
{:user-id 4 :uri "/2"}
{:user-id 1 :uri "/0"}
{:user-id 4 :uri "/3"}
{:user-id 5 :uri "/account"}
{:user-id 5 :uri "/1"}]
)]
(let [sorted-map-of-users (into (sorted-map) (group-by :user-id sorted-by-url))]
(println sorted-map-of-users)
(doseq [[user content] sorted-map-of-users ]
(println (str "----- " user "-------\n" content)))
(for [elem (seq content)] (println (str "--- " elem))) ;; this never seems to print
)
)
doesn't print the output I'd expectnberger: no particular pain, I’m looking at reframe and luminus templates and one has src and src-cljs and the other one has src/clj and src/cljs. Neither has a solution for test. I was wondering if there’s an advantage of one over the other.
I guess src/clj & src/cljs is preferred: you can be sure you are looking to the entire codebase if you look into src. I think that, and having a cleaner root dir are the factors in favor of that layout
I've seen some projects using src/main/{clojure,cljs} and src/test/{clojure,cljs}, I suspect for a similar reason
Is there a guide for setting up clojure.tools.logging in a library that will be consumed by other projects? I know how to set it up in my own apps, but I’m not 100% sure what to do about which logging dependencies go where?
@noisesmith: Thanks for the hints