This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-27
Channels
- # admin-announcements (9)
- # aws (1)
- # beginners (4)
- # boot (197)
- # cider (38)
- # cljsrn (70)
- # clojure (128)
- # clojure-russia (36)
- # clojurecup (1)
- # clojurescript (86)
- # core-typed (2)
- # css (1)
- # datomic (35)
- # editors-rus (4)
- # hoplon (22)
- # ldnclj (2)
- # mount (19)
- # off-topic (45)
- # om (63)
- # onyx (7)
- # parinfer (8)
- # yada (2)
hmm. any suggestions where to troubleshoot an IllegalStateException Attempting to call unbound fn
that shows up halfway through my functions? (as in, the first half of the file get properly defn'd; the second half are all unbound)
@curtosis: hard to tell without seing code examples... does it trigger when loading the function definitions or when calling the functions ?
stray close-paren at the end of the file was masking a missing close-paren earlier. operator error. sigh.
such a weird error, though.... it was different than "unable to resolve symbol", which is what I would have expected.
weird indeed
hi guys, is there anyway that we can add deps exclusion automatically when we have :pedantic? :abort
on in project.clj
I got this error java.lang.IncompatibleClassChangeError
, I wonder what is the possible causes of this error ?
If you compile with one version of Java and run with another, and they are incompatible. You won't get this error if you compile and run on the same version of Java.
hmm, in my case it's not. Since the whole thing is compiled and run on the same version of java
It may not be your code. http://stackoverflow.com/questions/1980452/what-causes-java-lang-incompatibleclasschangeerror
The java people have always allowed themselves to have binary incompatibility between major version changes. I've never used 1.8, but I presume there will be problems using 1.7 compiled jars when your main source code that calls it has been compiled with 1.8.
yeah it comes from the run-jetty from ring. But the lib itself doesn't have any problem with other people ( not the same project as mine ). But btw, I will ignore it for now since I use aleph server anyway
It is a runtime error so things could work fine for everyone else as they are not making the particular call you are making. The 'other people' are asking for trouble perhaps...
Hmm - taking a look at that SO answer shows that it can get more involved than any of my glib reasoning might suggest.
@cjmurphy: the problem occur when I just eval the deps and its function, I haven't made any function call yet.
@curtosis: hah, for me errors like these happen relatively often (for some reason I tend to quite often get weird errors most Clojure people don't encounter), I guess that's the downside of having regular syntax. I'm trying to make myself use paredit, hopefully this will mitigate that.
(defn say-hello [] (do (print "please type your name") (flush) (let [name (read-line)] (println "Hi " name))))
so you started your repl with lein repl in the terminal?
are you not seeing any dialogue or popup somewhere?
heres what happens when you do read-line in a different repl
notice the prompt for stdin on the bottom
here's a tweet from 2014 https://twitter.com/CursiveIDE/status/434902782860988416
yeah its a cursive thing
apparantly
I saw that tweet too, but with Cursive 1.0 being released, i was hoping it might work now
sorry about the painpoint, friend 😞
@johannjohann: thanks for your help!
am reading through land of lisp and trying out with all the coding exercise, i guess will just skip a chapter then
thats a fun book!
@johannjohann: @jh398: Yeah, this is still a limitation in Cursive, sorry. I’ll try to fix it soon.
@johannjohann: When it prompts in the minibuffer in Cider, does it only allow a single line to be entered?
@jaen "make myself use paredit" Is that something you can use with Cursive or has to be separately?
Hi All! I have a question about core.async/timeout channels: can I actually treat them as values and declare a timeout channel once and reuse it, e.g. in alt! calls, or I do need a new instance of such channel when I want to do a select using it?
IIRC you have to call timeout
each time you want to use it, since the channel is closed when the timeout elapses (that's how it works - you block until it is closed)
So if you do (timeout 100)
and (timeout 120)
they will probably timeout at the same time, not with 20ms separation.
Thanks for the clarification, jaen! I was confused a bit, 'cause somewhere I heard / saw a statement that timeouts are like values
You basically get a channel that will close in n
miliseconds, so you can block on it to sleep for that time.
Just keep in mind the timeout is counted from the creation time - if you call (timeout 1000)
keep the timeout channel around for 500msecs and only then take from it
So it's better to just straight up take from them at creation and if anything, pass around timeout duration as integer, or something like this.
Of course I can see some use cases for keeping a timeout channel around - for example you might want to delay the first time something happens by 2000msecs, but have it be instantaneous next time, so you can call timeout
once, keep it around and alt
on it.
Hi all. I’m trying out stuartsierra/component. It’s working fine, but I’m trying to understand the repl workflow. Before when using the repl-reloaded “pattern” without component, I was able to access the running system map and play around with it in the repl. But since .start and .stop are the only methods on SystemMap I’m not able to access components directly in the repl. Am I missing something obvious here, and if not, how do I access components in the system that I would like to invoke directly from the repl?
But I think you should try https://github.com/danielsz/system#boot-system (if you're using boot) or https://github.com/weavejester/reloaded.repl (if you're using lein)
They handle the basic scaffolding to store/start/restart system automatically on code changes.
hello all! i'm trying use refs in my code. i'm a bit confused when to use @ (deref) with refs? next code snippet works well without @ (deref)
(def vendor (ref {:id 102 :name "Alex" :money 150 :stones 5})) (def customer (ref {:id 102 :name "Mike" :money 50 :stones 20})) (defn stones-deal [customer vendor amount] (dosync (when (and (customer-has-stones? customer amount) (vendor-has-money? vendor amount)) (alter vendor assoc :stones (+ (vendor :stones) amount)) (alter vendor assoc :money (- (vendor :money) amount)) (alter customer assoc :money (+ (customer :money) amount)) (alter customer assoc :stones (- (customer :stones) amount)))))
is it correct to use (vendor :stones) in alter instead of (@vendor :stones)?
@mike1452: i'd use (:stones @vendor)
as you're using a keyword as a function to access the value of the ref (a map)
the difference between using the deref and not using it is when you are updating it with alter you just name the ref, when you want to read anything out of it deref it. it's more normal to also use the (:keyword map)
to access a value in a map, unless it's deeply nested, then use (get-in [:k1 :k2 ...] map)
.
@makrf: thanks!
Wondering if there’s a quick way to change a string into a function name, so I can call it at runtime?
I’m not sure how multimethods would help. Assume I don’t know what the name of fn before it is called.
@mudphone: What are you trying to achieve?
then depending on a color input by a user, call that function, or a default, if that function doesn’t exist
I don’t want to have to have a big cond
with input to fn… just want to call the fn if it is in the ns
So you know have the fns you want to call conditionally defined alredy?
What kind
There are lots of ways to do this
You could just use a map
Or multimethods like roberto suggested
I don’t think using resolve is idiomatic
(def color-fns
{"blue" (fn [color]
:blue)
"green" (fn [color]
:green)})
((get color-fns "blue") "some-arg”) ;=> :blue
With multimethods:
(defmulti color :name)
(defmethod color "blue"
[_]
;; Do some processing
:blue)
(defmethod color "green"
[_]
;; Do some processing
:green)
(color {:name "blue"}) ;=> :blue
i understand that resovle
isn’t idiomatic, but I don’t want to wire up the function (via cond or multimethod, etc.)