#clojure logs

2012-07-15

00:21wingygood morning
00:34gfredericksyou shouldn't have said that so loud; my son woke up and thinks it's morning
00:39devthi'm pretty sure this used to return true: (seq? [1 2 3]). at least my 6 month old source code assumes so.
00:39devthmy clojure is super rusty - is there a function that returns true for both lists and vectors?
00:40devthlooks like coll? is what i'm looking for.
00:44zakwilson,(doc coll)
00:45zakwilson,(doc coll?)
00:45zakwilson,(clojure.repl/doc coll?)
00:46musicalchair&(doc coll?)
00:46lazybot⇒ "([x]); Returns true if x implements IPersistentCollection"
00:48devthcool.
01:20technomancyhttps://github.com/technomancy/limit-break
01:24duck1123so does the repl have the full scope?
01:24technomancyyeah
01:24duck1123sweet
01:24technomancyit's not as nice as swank.core/break, but it's a start
01:25technomancywell, it's basically useless right now because it requires trampoline and stdin
01:25technomancybut it's a start
01:25technomancy25 lines
01:30yonatanewould a clojure IDE written from scratch in clojure be cool or redundant?
01:31duck1123there's clooj and light table
01:32duck1123possibly others
01:32yonataneis light table going to handle projects?
01:32sprocI'm trying out Clojure and running into an issue trying to load a data structure from a file with load-file: http://pastebin.com/qnBRCg97
01:33duck1123yonatane: that's the plan, I believe
01:40georgekhi, I'm trying out the simple example of lein-cljsbuild (with lein2) on Windows XP, everything works up to 'lein ring server-headless 3000', when I get the error "Could not locate example/routes__init.class or example/routes.clj on classpath"
01:41duck1123sproc: have you verified that you're getting the correct command line args?
01:41georgekno, I'm just following the readme in the example
01:42duck1123georgek: is example.route what you named your file?
01:43georgekit's named example.routes which conforms to the error msg
01:43georgekI copied the example from lein-cljsbuild to my directory
01:44duck1123so you have a file at src/example/routes.clj with a ns of example.routes
01:44georgekright
01:46duck1123the advanced example? Looks like it has a non-standard clj src path. Make sure you either have it in src/ or that you have the :source-path key set in project.clj
01:47georgekit's the simple example, yes the source-path is set in project.clj
01:47georgeksorry I answered 'right' to the spirit of your first question :)
01:48sprocduck1123: I modifed the app to print the command-line args, and they were as expected. Then I uncommented config-map and noticed that those print statements didn't execute before the stack trace was printed, despite them coming first. The exceptions are from clojure.lang.Compiler; is it trying to compile rather than interpret?
01:48duck1123if you launch a repl can you require the ns?
01:49georgekI haven't launched a cljs repl before, or do you mean a clj repl?
01:50duck1123a clj repl. It can't hind your clj files here
01:50duck1123sproc: I know there's an issue with defining vars within a do, I wonder if something similar is hapening here
01:51duck1123best I could say is "don't do that"
01:51sprocduck1123: within a 'do'?
01:52sprocI'm not familiar with that term.
01:52duck1123sproc: Yeah, I can't remember the full details, but if you do something like (do (def a 1) (+ 1 a)) it wouldn't work... or something
01:52sprocduck1123: Oh, I see
01:52sprocduck1123: Alright, I think I can work around that. Thanks for the help.
01:53duck1123I would just read the data from the file, and assign it in your ns
01:54duck1123you can look at what I do here" https://github.com/duck1123/ciste/blob/master/src/ciste/config.clj
02:15TcepsaI also have a cljs question: In the ns form at the beginning of the cljs file, I'm attempting to (:use [clojure.string :only [split]]) and then later on I call (split "60 61 62" #" ") but it doesn't seem to work.
02:15Tcepsa(clojure.string/split "60 61 62" #" ") works just fine though
02:16TcepsaAside from "well just do it that way then!" what should I be doing so that I can just call split instead of having to fully qualify it?
02:25cheater__hey guys what am i doing wrong? user=> (if (2 > 1) 2 3)
02:25whamiedprefix notation :)
02:25cheater__this gives me: ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
02:25cheater__hmm
02:25cheater__right
02:25cheater__i keep forgetting that always
02:25cheater__damn
02:26whamiedits okay ull get used to it :)
02:27cheater__is there a good pastebin for clojure?
02:28duck1123refheap is fairly popular, if not gist
02:28cheater__i've written a recursive function and it's broken :)
02:28cheater__trying to implement nth
02:28cheater__oh wait i think i know what's up
02:29cheater__https://www.refheap.com/paste/3616
02:29cheater__any tipz?
02:30IceD^hey guys
02:30cheater__hi
02:30IceD^I'm tasked to create java bindings for our services, but I cba writing any java
02:31IceD^'d like some good tutorial on wrapping clojure in java classes
02:31cheater__write one!
02:32cheater__duck1123, whamied - any ideas why this function isn't behaving like nth? :)
02:34whamiedit looks to be working for me
02:34whamiedbe sure to use defn
02:34whamiedinstead of just fn
02:35whamiedthat way you can reference it later on
02:36duck1123looks like you're both peeling of the top element and decrementing the index
02:36cheater__no i have fn because it's for 4clojure
02:36cheater__and the error was that 4clojure wanted it all on one line
02:36cheater__derp
02:36whamiedohh okay haha
02:36whamiedso you got it to pass now?
02:40georgekso I've been trying some things with no luck. One weird thing is that starting lein repl from the cljsbuild-example-simple starts the repl with the intro text, but then prints 'nil' and the repl basically is frozen.
02:40georgekI can create an empty lein new project with clojure 1.4 and the repl works normally
02:43cheater__whamied: yup!
02:43whamiedgreat!
03:01cheater__guys why does this return [3 2 1] and not [1 2 3]? ((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 3)
03:02cheater__i basically see conj (conj (conj [] 1) 2) 3
03:02duck1123,(conj [1] 2)
03:03cheater__duck1123: not sure what you mean?
03:03duck1123conj inserts into the most efficient place for the datatype
03:03duck1123so vectors and lists insert differently
03:03cheater__oh
03:04duck1123Clojurebot is gone
03:04cheater__yeah
03:05cheater__does clojure have pattern matching?
03:05duck1123&(conj [1] 2)
03:05lazybot⇒ [1 2]
03:05sjlcheater__: google around for core.match
03:06cheater__no i meant like argument pattern matching
03:06cheater__kinda like erlang or haskell
03:06cheater__i think you mean regex?
03:06sjlcheater__: No, core.match has nothing to do with regexes
03:06sjlIt's pattern patching.
03:06sjl*matching
03:06cheater__oh right yeah
03:07duck1123I think someone tried to build something like that once, but no
03:07cheater__duck1123: https://github.com/clojure/core.match/ looks good
03:07duck1123we have multimethods
03:07sjlIt's not integrated tightly into the language like haskell, but it's still acceptable concise to use
03:07cheater__mhm
03:08sjlI'm sure you could write a macro to define functions with pattern matched args using core.match
03:08sjlI'm not entirely sure it'd be a good idea though...
04:02xumingmingvmacro can not be passed to a HOF right?
04:03RaynesNo.
04:04arohnerxumingmingv: but you can do (map #(my-macro %) [:a :b :c])
04:04cheater__are there higher order macros?
04:04arohnerno, but there is an old contrib project playing around w/ applying macros
04:06cheater__what does the hint here mean? http://www.4clojure.com/problem/27
04:07cheater__Hint: "racecar" does not equal '(\r \a \c \e \c \a \r)
04:08xumingmingvhttps://github.com/xumingming/storm/blob/issue72/src/clj/backtype/storm/testing4j.clj#L58
04:08xumingmingvhttps://github.com/xumingming/storm/blob/issue72/src/clj/backtype/storm/testing4j.clj#L85
04:08xumingmingvthen do you have any advice how to extract a common function from these two functions?
04:09xumingmingvhere , with-local-cluster and with-tracked-cluster are macros.
04:09xumingmingvall the logic are the same, just used different macro
04:10scottjcheater__: I think they just want you to know that a string is not a list of characters, you have to seq on a string to get that (or use a function that itself calls seq). not sure how helpful that is
04:11cheater__oh
04:12scottjcheater__: ahh, I see, it probably is necessary to know that
04:12cheater__thx scottj
04:21logaanwith datomic is it possible to traverse a reference in reverse as part of a query?
04:23logaanas in this example: https://gist.github.com/3115870
04:35fureddoHi, I'm new to Clojure. I'm trying to implement a simple card games to get into the language.
04:36fureddoI have a deck of cards defined as (def deck (ref '(c1 c2 c3 c4 c5))) where c1 c2 c3 are cards. I want to pop a card off the deck. How can I do that?
04:39fureddoIf I call pop, I lose the card on the top. That's ok, but I want to move the top card into another list instead. Do I need to copy the top card using (peek deck)?
04:39logaanwhen you de-ref your deck you will get an immutable value
04:39logaanthis means that you can query it multiple times without loosing any info
04:41logaanso you can call do:
04:41logaan(let [deck @deck top (first deck) new-deck (rest deck)] [top new-deck])
04:41logaanand you'll get back a vector (which you can think of as a tupple, with the new deck (sans the card you popped) and the card
04:41fureddoI see... Interesting.
04:41logaanyou may then chose to reset! the deck back to new-deck
04:46logaanfigured it out. updated gist with solution if anyone's curious.
05:47cheater__Raynes: hey, can i get lazybot in #codez ?
05:54cheater__guys how can i find my clojure.jar? i can't seem to find it anywhere, and i can run lein repl
05:59cheater__found it :)) it was named differently.
07:54cheaterdoes clojure have TCO or do i need to call recur?
07:55cheaterso basically if in my definition of funcfoo, if i call funcfoo in the tail, will i get a stack overflow?
07:56cheaterthere's one too many "if" there :)
07:59hyPiRionyou'll have to use recur.
08:08antares_cheater: recur exists because JVM and JavaScript VMs do not have TCO
09:11wingy_is there an error in the doc here: http://clojuredocs.org/clojure_core/clojure.core/defprotocol
09:11wingy_shouldn't extends? take a protocol first and then a type
09:12wingy_oh
09:12unnalidoesn't it?
09:12wingy_my mistake
09:12wingy_haha
09:12wingy_just woke up .. must be it
09:12unnali:D!
09:17wingy_so basically there is 2 polymorphism systems in clj .. one using multimethods and another using data types (defrecord, deftype) and protocols (defprotocol)
09:18wingy_the latter was added for java interop?
09:18wingy_so that you can write clj code and use them in java right?
09:19wingy_also a simpler polymorphism based on type rather than dispatching value
09:19wingy_better performence i guess
09:20cjfriszI'm a big fan of data types myself
09:20wingy_wasn't the point of FP not to think in classes/objects
09:20cjfriszAlthough I'm a speed junkie
09:21cjfriszRecords and protocols may resolve to classes and objects, but the concept is still valid and very useful
09:21cjfriszScheme has a similar record system
09:21cjfriszAs does Haskell
09:22unnalicjfrisz: ... Haskell's widely believed to be bollocks (despite heavy use) ...
09:23cjfriszunnali: ... Touche?
09:23cjfriszI'm not a big types guy, but I hung out with a whole bunch of them while I was getting my MS
09:23wingy_there is no inheritance in the type/protocol system in clj?
09:23cjfriszType guys (and girls), that is
09:24cjfriszwingy_ : There *is* inheritance, but it's waaaay more awesome than Java
09:25antares_wingy_: multimethods let you easily implement inheritance-like semantics. Protocols do not have inheritance, thanks god. That's what makes them flexible.
09:26wingy_antares_: yeah
09:45wingy_does anyone know what the problem is here: https://gist.github.com/3116981
09:46wingy_hm it worked in lein repl but not in Light Table
09:46wingy_what is wrong with light table
09:46schaniwingy_: i've had a very similar problem with a defprotocol/deftype
09:46wingy_they changed something in defrecord in clj 1.5?
09:47schaniit seems lighttable does some strange magic with defprotocol
09:47schanii thought lighttable used clojure 1.4?
09:48wingy_*clojure-version*=> {:major 1, :minor 5, :incremental 0, :qualifier "ibdknox5"}||
09:48schanihmm
09:50wingy_why is it allowed to not implement all methods by interface in a defrecord?
09:50schaniwingy_: quite strange - even after connecting to a clj 1.4 lein project, it reports version 1.5
09:51wingy_schani: yeah i think it is using some feature in 1.5 so it must be on 1.5
09:51schanii'm not familiar with 1.5 at all, so no idea
09:51wingy_since it's using 1 jvm so it cannot switch
09:52schaniit's supposed to switch when you do "connect"
09:52wingy_probably the end implementation could be running 2 jvms .. one for our project and the other for light table
09:52cjfriszWow...you can tell that I've been out for a while when I didn't even realize that 1.5 was ready for public consumption
09:52wingy_cjfrisz: its not
09:52wingy_still in development
09:53wingy_anyone who knows why im not enforced to implement all methods by interface in my record? what is the point?
10:14duck1123wingy_: that's by design
10:16wingy_duck1123: what is the purpose?
10:16duck1123not forcing the programmer to have to implement a million methods before they can tes
10:17duck1123it should throw an exception for the rest IIRC
10:17wingy_but if all collections are implementing an Iterable protocol but now they are not forced to implement the methods a user will find it weird that its documented it is using that interface but the "count" method is missing
10:17wingy_for some implementations
10:18wingy_you mean before they can test?
10:19duck1123but if the call count, it'll just throw the not implemented exception saying that it was supposed to be implemented, but never was.
10:20duck1123If you're implementing a protocol, you should implement all the methods, but no one is forcing you to
10:24wingy_i c
10:24wingy_i get an AbstractMethodError yobistore.core.Person.run_slow()Ljava/lang/Object; yobistore.core/eval1089 (NO_SOURCE_FILE:1) error when trying to access a method not implemented yet
10:25wingy_the error message wasn't to clear about what was hapepning
10:25wingy_i guess everyone should read it as NOT IMPLEMENTED YET
10:25duck1123I'm thinking of gen-claas that has the clear error message
10:27duck1123were you re-defing the protocol in the repl?
10:28cheaterhi again
10:28cheaterdoes clojure have automatic tco?
10:28duck1123cheater: no, use recur
10:29cheaterantares_: hmm just saw your answer
10:29cheaterduck1123: ok
10:29cheaterduck1123: are there targets that do tco?
10:29duck1123recur has the benefit of asserting it is actually a tail call
10:30cheateri understand, as antares_ said, that recur exists because JVM and JS are too stupid to figure it out
10:31duck1123cheater: That was the original reason, but it's also a design decision at this point. Rich said he wouldn't add TCO unless he could guarantee it would work in all cases
10:31duck1123is most cases, you can get what you want without needing recur anyway
10:31cheaterright
10:32cheatercan i?
10:32cheaterby just recursing, without taking care around the stack overflows?
10:32wingy_duck1123: yeah
10:33duck1123most of the time when you want to recur, you can make it a lazy seq to acomplish the same goal
10:33cheaterah ok i see what you mean
10:33cheaterhow do you make lazy stuff?
10:33cheatersome sort of yield kw?
10:33wingy_cheater: lazy-seq
10:33cheaterl@@king, thx
10:33duck1123(lazy-seq (cons ...))
10:34cheateryeah just read the doc
10:35duck1123Programming Clojure did a good job of explaining how to not need recur. (at least in the 1st edition)
10:35cheaterhey speaking of doc, i like that it works like in python. one question though. is there something like python's "dir"?
10:35cheaterdocs in the repl are the biggest help ever when learning a new lang
10:36cheateri dread haskell for that reason
10:37wingy_(doc doc)
10:38hyPiRion&(doc doc)
10:38lazybot⇒ "Macro ([s]); "
10:38wingy_do you guys think a java crash course could be helpful in understanding clojure
10:39wingy_seems that the java interop is everywhere. perhaps it could be good to know the fundamentals about java?
10:39cheaternot from what i've seen so far
10:39hyPiRionIt's good to know the JVM, but not essential.
10:40hyPiRion,(doc doc)
10:40hyPiRionWeird, the doc shouldn't be like that.
10:41wingy_,(source doc)
10:41Bronsa&(doc doc)
10:41lazybot⇒ "Macro ([s]); "
10:41wingy_&(source doc)
10:41lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
10:41cheateri know exactly 0 about java but then i'm a cold beginner
10:41duck1123It's helpful to know your way around a javadoc
10:41wingy_lynda java crash course seems nice
10:42hyPiRion&(doc assoc)
10:42lazybot⇒ "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
10:42wingy_why is there & and , for running code
10:42wingy_different bots?
10:42hyPiRionyes.
10:42wingy_who owns these bots? can i just create one and use it here?
10:43duck1123, = clojurebot & = lazybot
10:43duck1123hiredman and Raynes respectively, I believe
10:47Bronsayou can also eval an expression inline like ##'this
10:47lazybot⇒ this
10:47hyPiRionlazybot: botsnack
10:47lazybothyPiRion: Thanks! Om nom nom!!
10:47hyPiRionI find that oddly comforting.
10:49wingy_lazybot: hello
10:49wingy_:(
10:52wingy_when will 1.5 come out?
11:05wingy_one good way to learn clj i think is to read stackoverflow questions .. so many great answers
11:09wingy_so there are 4 reference types (var, ref, agent, atom) for changeable state .. but when i define the latter 3 it seems that i bind them all to a var (def v (ref 0)). this mean that the latter 3 are values which have to be bound to a var?
11:12duck1123they don't have to be bound to a var, but they often are
11:12hyPiRionYou can bind them with a let as well.
11:13hyPiRion&((fn [a] (swap! a inc)) (atom 0))
11:13lazybotjava.lang.RuntimeException: Unable to resolve symbol:   in this context
11:13hyPiRion&((fn [a] (swap! a inc)) (atom 0))
11:13lazybot⇒ 1
11:49wingy_duck1123 hyPiRion: ok so they are values just like collections and scalar values but Var is not a value
11:49wingy_Var is a mere reference to it's binding value
12:04wingy_it says in the doc "Only Java fields, Vars, Refs and Agents are mutable in Clojure."
12:04wingy_isn't atom mutable as well?
12:41edonhello, what resource would you suggest for learning clojure to someone that is already quite familiar with functional programming?
12:44hyPiRionedon: 4clojure.com
12:56kmicuwingy_: atoms are mutable
12:57kmicuedon: http://clojurebook.com/
13:11wingy_they should provide a github repo for us to change the reference doc
13:14kmicuwingy_: it is not so hard to join dev http://clojure.org/contributing
13:16duck1123In the mean time, you could add examples to clojuredocs
13:17wingy_i want to correct doc
13:17wingy_ill read it though later
13:17hyPiRionkmicu: About that, would it still be possible to join clojure-contrib, even though it's not monolithic anymore?
13:18hyPiRionI suppose yes, but I've not really looked into it.
13:22duck1123If you have a contrib lib that didn't make it, it's because it was either ill-conceived, or no one cared about it
13:22duck1123I'm sure if you were willing to be point on it, you could get it promoted
13:23duck1123but check if there's a non-contrib that has taken it's place
13:25hyPiRionduck1123: I meant "join" as in signing the CA with both clojure and clojure-contrib on it.
13:42georgekhi, I'm trying to get the cljsbuild example at https://github.com/emezeske/lein-cljsbuild/tree/master/example-projects/advanced working, and I can get up to 'lein trampoline cljsbuild repl-launch firefox http://localhost:3000/repl-demo', but then I get 'Could not find the main class: and. Program will exit.' -- this is on Windows, so it's some file path issue; I've seen references to changing colons to semicolons in a cljs build scri
13:42georgekpt but I don't know where to do this using cljsbuild, any ideas?
13:45duck1123georgek: still no luck with that?
13:45georgekI've made progress actually, just a different problem that's the same :)
13:45duck1123oh, that, ok. :)
13:45georgeksometimes using Windows is like wearing a hairshirt I guess
13:46duck1123You know what Windows is good for? Running a linux VM. :)
13:46georgekha
13:46georgekyes, I have one sitting here I can use
13:46georgekI'm just stubborn ;)
13:48duck1123does repl-rhino work?
13:49georgekI haven't tried it
13:49georgeklet me find the syntax
13:49kmicugeorgek: example-projects/simple works?
13:49duck1123on the subject of cljs and repls. What's the current state of running cljs repls inside of emacs?
13:49georgekyes kmicu
13:50georgekI've done it successfully with cljs one duck1123
13:50kmicuduck1123: no problem? ;)
13:50georgekthere are other ways like with inferior-lisp too
13:50sirsublimeHey, everybody! Could someone help me out with leiningen? I need to compile some Java code, but even the simplest class fails.
13:51duck1123are you guys just launching with a terminal inside emacs, or what?
13:51kmicugeorgek: cljs1 works on windows, but it is half year old :]
13:51duck1123I'm just now turning my attention back to cljs
13:52georgekyes kmicu, and with lein1x only it seems, that's why I'm trying cljsbuild
13:52georgekduck1123, you can do with with a terminal, or inferior-lisp directly
13:53georgekduck1123, repl-rhino gives the same error, 'could not find the main class: and.' -- file path problem somewhere
13:54georgekat least it's narrowed down to either cljs, lein, or cljsbuild ;)
13:54georgekmy working directory does not contain spaces btw
13:55georgekis there a way to print what paths cljs is using in process
13:55kmicugeorgek: maybe because folders start with dot? https://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/advanced/project.clj#L20
13:55duck1123not sure of cljs, but lein classpath might help you
13:57georgekyep I bet it's bombing on my .m2 file path, in 'Documents and Settings'
13:57georgeklein puts .m2 there as it's the user home though
13:57georgekmaybe a way to reconfigure that
13:58kmicugeorgek: but then simple version fo example project should faild also?
13:58TimMcsirsublime: What --version of lein? And how are you instructing lein to compile the Java?
13:58duck1123lein has a :local-repo key
13:58georgekmaybe not kmicu, as simple does not launch a repl
13:59georgeksomething to do with repl launch screws it up?
13:59georgeksimple is just compilation
14:00darrenaustinHey folks. Newbie here. I was trying to install kibit for lein 1.x and ran into a NPE when running "lein plugin install jonase/kibit 0.0.4". Anyone know what might be causing this?
14:00georgekwhat OS?
14:01duck1123Is it normal that my cljs repl has no line editing capabilities at all?
14:01darrenaustinLion on a Mac.
14:04sirsublimeAlright, Lein version 1.7.1
14:05sirsublimeI have a simple class in src/java as follows:
14:05sirsublimepackage clj2java;
14:05sirsublimeimport clojure.lang.IFn;
14:05sirsublimeimport clojure.lang.RT;
14:05sirsublimeimport clojure.lang.Symbol;
14:05sirsublimeimport clojure.lang.Var;
14:05sirsublimepublic class Clj2Java {
14:05TimMcugh
14:05sirsublime public static void main(String[] args) {
14:05sirsublime System.out.println("Hello.");
14:06sirsublime }
14:06sirsublime}
14:06sirsublimeSorry.
14:06TimMcsirsublime: Use a pastebin.
14:06TimMcI have you on /ignore.
14:06TimMcduck1123: I noticed that too.
14:06sirsublimeThere we go: http://pastebin.com/3dv84Pmv
14:07duck1123ok. I used rlwrap and it's slightly better now
14:07duck1123I'll just do that in the future
14:07sirsublimeVery basic stuff.
14:07TimMcsirsublime: OK, do you have a pastebin link now?
14:07sirsublimeYep, here it is: http://pastebin.com/3dv84Pmv
14:08TimMcOK, could you pastebin the project.clj file?
14:09sirsublimeHere's project.clj: http://pastebin.com/9kad3ZiR
14:10sirsublimeThis is very basic stuff. I just want to set up lein to compile java, so I can do some actual work. My idea was, that a class this basic should compile with no problems. But I guess I am missing something.
14:11hyPiRionsirsublime: Ok, where did you place the java-file?
14:12hyPiRionthe path to it should be src/java/clj2java/Clj2java.java
14:13sirsublimeAlright, this explains everything. Sorry, I'm not used to Java's strict path requirements.
14:13hyPiRionNo worries
14:15TimMcsirsublime: You got the syntax wrong for :java-source-path.
14:15TimMchttps://github.com/technomancy/leiningen/blob/1.x/sample.project.clj#L171
14:16TimMcsirsublime: By the way, Java and Clojure *both* have strict path requirements.
14:16sirsublimeOk, **now** it works.
14:17duck1123so if I call repl/connect from my webpage and use repl-listen, I should be able to require my lib, right?
14:17duck1123"Error evaluating:" (require (quote [jayq.core :as jayq])) :as "cljs.user.require.call(null,cljs.core.vec([\"\\uFDD1'jayq.core\",\"\\uFDD0'as\",\"\\uFDD1'jayq\"]));\n"
14:17sirsublimeWell, I've started with the language not long ago. Never even touched Java before. So, thanks for the help. :)
14:18sirsublimeBtw, is there any way to make the error messages a bit friendlier? Or do you guys just learn to read them like the Matrix code?
14:18TimMcThe latter. :-)
14:18duck1123sirsublime: given time, your eyes learn to find the important parts
14:19duck1123usually, just look for your clj file names
14:19TimMcSome of the compile errors are pretty opaque, unfortunately. Runtime stack traces are a lot easier to read.
14:19TimMcIn the REPL, use (pst) to get a nice stack trace after something errors out.
14:21kmicugeorgek: did you get "Running ClojureScript REPL and launching command: (firefox http://localhost:3000/repl-demo)... after running "lein trampoline cljsbuild repl-laun..."?
14:21sirsublimeOh, thanks, guys. :)
14:27georgekkmicu, yes
14:27georgekI think the error is unrelated to the launch-repl command
14:28georgekI'm nuking my lein as we speak and starting from scratch at a top level dir, see if that fixes file path issues
14:34duck1123Ok, I'm still having no luck requiring any namespace from cljsbuild's repl. What am I missing?
14:37georgeksilly question, but are you using :as?
14:37duck1123yes
14:38duck1123(require '[jayq.core :as jayq])
14:43georgeki wonder if you have to use it in a ns
14:43georgekjust watched an old screencast where they did that, though that was 9 months ago
14:53georgekso in trying to get lein on Windows up to a dir path without spaces, I edited the .bat (https://raw.github.com/technomancy/leiningen/preview/bin/lein.bat ) to set lein_home where I wanted. However it still creates its .m2 in my user home dir, which is below ".../documents and settings/..." as usual, anyone know how to set the .m2 location?
14:59duck1123you can set :local-repo in your project (possibly also in profile?)
14:59georgekgood idea about profile, I'll check that -- there must be a system-wide setting too though?
15:08ro_stis it possible to have noir serving / but somehow have nginx or apache serving all the static assets?
15:08ro_sti want to be able to take advantage of html5boilerplate's caching configs
15:10duck1123ro_st: If all your static resources have a static component (ie. /assets/) you can just have your http server bypass the proxy and serve those directly
15:12ro_stcool
15:13georgekso it appears I can change where maven stores its artifacts if I can get to the maven settings.xml (normally in /conf/settings.xml) but this doesn't seem to be in the lein jar, does lein even use the maven settings.xml?
15:13georgekotherwise maven stores in user.home/.m2 by default
15:13georgekwhich I'm trying to avoid
15:25georgekso this is weird; now I have lein in a dir path without spaces, but .m2 is still in a path with spaces; running the cljsbuild advanced project now doesn't give me the 'Could not find the main class: and. Program will exit.' error, but instead Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: EOF while reading, starting at line 1
15:25technomancygeorgek: lein1 uses settings.xml (by accident) lein2 uses :local-repo in project.clj IIRC
15:25technomancyor you can put it in your :user profile to use it across all projects
15:26georgekcool, thanks, I'll try that
15:42georgekmy profile's local-repo isn't working somehow, here's the profile and error, https://www.refheap.com/paste/3618
15:42georgekit looks right according to what technomancy just said and this SO answer, http://stackoverflow.com/questions/11460283/how-can-i-make-leiningen-2-respect-the-local-repository-path-in-mavens-settings
15:43technomancyneeds a closing }
15:43georgekson of a biscuit
15:51georgekcool, it's very close, now I'm just getting this weird reader error when trying to launch the repl with trampoline, https://www.refheap.com/paste/3619, Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: EOF while reading, starting at line 1
15:51georgekthe page is served at localhost OK
15:52technomancyif you export DEBUG=y you can see exactly what shell command trampoline is using
15:57georgekinteresting, while lein now downloads artifacts to my local-repo, the trampoline command uses artifacts from the old .m2 location in user.home/.m2
16:00technomancyhm; that'd be a bug. not sure if it's one in leiningen or pomegranate.
16:00georgeki'm going to try reboot for the heck of it
16:01wingy_clojuredocs is best .. the examples are such a valuable source
16:10yonataneIn the Transients page it says: "Note that not all Clojure data structures can support this feature, but most will. Lists will not, as there is no benefit to be had.". Why is that?
16:11yonataneyou know what, let me read through first
16:14Raynescheater: You certainly can.
16:15Raynescheater: Do you own that channel?
16:20georgekso setting local-repo in lein profiles and/or the project.clj downloads artifacts to the local-repo; running ring with lein ring server-headless port works and uses the local-repo; but then when running lein trampoline like 'lein trampoline cljsbuild repl-launch firefox http://localhost:3000/repl-demo', it starts downloading to the maven default, not local-repo
16:20Raynestechnomancy: I've switched to nrepl.el. I feel so liberated.
16:21technomancyRaynes: muahaha
16:23Raynestechnomancy: It's so awesome. SO AWESOME.
16:23RaynesShivers me timbers.
16:24technomancyit's not _that_ awesome ... yet
16:24technomancyit's the potential awesome that'll get you
16:24Raynestechnomancy: It is not SLIME, which makes it awesome.
16:24Raynestechnomancy: Why is it that C-c C-d opens a new buffer?
16:25technomancyas opposed to...?
16:25nedRaynes: what are the advantages of nrepl.el over slime
16:25RaynesPrinting to the existing repl buffer.
16:26technomancyRaynes: mostly because it's designed to be invoked from clojure-mode buffers
16:26Raynesned: It isn't SLIME and doesn't require crazy hacks for there to be a 'jack-in'.
16:27RaynesThat's my favorites.
16:27RaynesThose are my favorites*
16:27wingy_if i change a state in a ref/atom/agent, could the previous state still be retrieved or is it "lost" since i have no reference to it?
16:27technomancyRaynes: it doesn't even print stack traces yet, much less clj-stacktrace
16:27technomancyspeaking of which, I need to bug Chouser about obsoleting that too
16:28Raynesned: nrepl.el isn't better than SLIME in functionality yet, but the whole concept is loads better.
16:28RaynesMight even be some releases every now and then!
16:28nedRaynes: hmmm im playing with it now
16:30Raynestechnomancy: You're kinda ruining the excitement.
16:31technomancyRaynes: no, I'm trying to get you to prove me wrong
16:31technomancyRaynes: grab one of these and join the party: https://github.com/kingtim/nrepl.el/issues
16:31Raynestechnomancy: Well you're right, so how w...
16:31RaynesOh, I see.
16:31RaynesYeah, no, Raynes doesn't do elisp.
16:31technomancycurses!
16:31Raynesrefheap.el was out of necessity.
16:31Raynes:p
16:32technomancywell in that case there's plenty of backend pieces still needed: https://github.com/technomancy/limit-break
16:32technomancyhttps://github.com/kingtim/nrepl.el/issues/13
16:32Raynestechnomancy: Can I call it gadget?
16:32technomancyRaynes: no, it has to be Javert
16:32technomancysorry
16:33RaynesNO DEAL!!1!!!
16:33technomancyit Has Been Decided
16:33gtrak``has it been thought of before, maybe to fix clojure android dev by porting clojurescript to emit java? that would remove the run-time heaviness
16:35gtrak``you don't really need eval there either
16:35gtrak``maybe not 'fix', but another option
16:36Raynestechnomancy: Okay, I'll consider this.
16:36Raynestechnomancy: I'll do this if you do stacktraces. ;p
16:37eph3meralso, recently I saw some JavaScript code that used dollar signs for variable names, like $myVar etc, note that I'm not talking about the jQuery style of $(myVar)... the dev in question, when asked why, I believe said that it came from clojure or it was a standard or stylistic suggestion from clojure
16:37eph3meralwhere the $ indicates a local var
16:38eph3meraland all other vars are global or are properties of an instance or class
16:38RaynesI think he might be on drugs.
16:38eph3meralhahah, he was pretty weird
16:38eph3meralI'm being told it's Scheme in ##javascript
16:39RaynesClojure certainly has no convention like that.
16:39eph3meralScheme i a "dialect" of lisp right?
16:39eph3meralRaynes, ok great, thanks, that's what I wanted to know
16:39RaynesScheme is indeed a dialect of Lisp as well.
16:40mononofuis there a better REPL than the default one?
16:41technomancymononofu: yes, thank goodness
16:41eph3meralRaynes, cool thanks, g'day :)
16:41technomancythe default one's a joke
16:42mononofutechnomancy: great, I was a bit put off by it. could you give me a name or a link?
16:42technomancyoh yeah; sorry
16:42technomancytry `lein repl` from http://leiningen.org
16:43mononofuthanks :D
16:43cheater_i strongly suggest you use lein 2 for the repl
16:43cheater_because it's so much better
16:44yonataneRegarding transients again, so where a mutable vector can mess with its existing internal array, a list would have to rebuild itself anyway? Is that why transient lists are pointless?
16:44yonataneand on the other hand, a list is not rebuilding itself all the time, and will behave the same as a transient
16:46yonataneactually i'm thinking about functions like replace. I'm not sure how it is implemented for lists.
16:48gtrak``yonatane, PersistentList is a pretty simple class
16:49gtrak``it has 3 fiields: private final Object _first;
16:49gtrak``private final IPersistentList _rest;
16:49gtrak``private final int _count;
16:51Raynestechnomancy: swank.commands.inspector is what I should be looking at, right?
16:55yonatanegtrak``: so to replace a value in the middle of a list, you'd have to tear it apart
16:55gtrak``yea
16:55gtrak``there's no benefit
16:55gtrak``it's just a cons cell with a count
16:56yonataneunlike vector where you have random access to the internal array
16:56gtrak``yonatane, yes, but it's not really an 'array'
16:56yonataneyeah
16:57gtrak``yonatane, actually, in java LinkedList is usually slower than ArrayList even when you think you would use one due to cache misses
16:58yonatanenot sure what cache misses are
16:59yonatanebut i read that allocating the array should be really fast
16:59yonataneand copying. not sure
17:00yonatanewill check
17:02gtrak``yea... copying the array when you need to grow it is generally faster than the aggregate lookups of list elements spread in different parts of heap. If you don't do a lot of inserts in the middle it'll lose?
17:02wingy_it says in the reference doc "Most data structures are immutable" .. what data structures are mutable in clj?
17:04georgekdoes anyone know what/where the difference might be here -- when running 'lein trampoline repl' the contents of the temp trampoline file (created with the Windows batch file) all refer to jars in my :local-repo; but when running something like 'lein trampoline cljsbuild repl-launch firefox http://localhost:3000/repl-demo' it starts downloading jars to the original default .m2 repo in user.home/.m2
17:04gtrak``wingy_, transients
17:04wingy_gtrak``: right
17:04georgekso trampoline knows about the local repo, but not when downloading what it thinks is missing
17:05Raynestechnomancy: Holy crap. Raw :use and everything.
17:19wingy_what is the best way to make an iOS and Android app in clj land
17:19sjlDo I need to do something special to get line/numbers and/or locals with clojure-mode + lein-swank? http://i.imgur.com/DoD7I.png
17:19wingy_cljs + phonegap with clj remote server?
17:20Raynessjl: Where do you expect line numbers?
17:20sjlah right, nevermind on the line numbers
17:20RaynesIn this case, there is no line number where the error occurred because you executed the code in the repl.
17:22sjlyeah, I see the line numbers working when I move the problem inside the actual file
17:23sjlbut there are still no locals listed
17:26georgekdoes anyone have a cljs project that uses lein2 I could try to run to see where my setup is failing? the cljsbuild examples are for lein1x
17:27georgekthe failure point is when I try to launch a repl, I can compile a project and run the web server OK
17:37Raynestechnomancy: ping
17:43sprocI'm loading some external config parameters, and so my config file just contains a Clojure map with values defined, and then I'm loading a (load-file "file") in my application; is this a good practice?
17:44sprocThe reason I'm prompted to ask is that it seems to work fine if I call (load-file) from the top level, but if I wrap it in a let, all of a sudden nothing can see the map. I've got the same namespace declared in both files (application and config file).
17:45georgekthe let binding is only in the let
17:46sprocI'm not binding that in the let, though, the only let-binding I'm doing is unrelated and then the (load-file) is called within the body of the let.
17:46sprocSince the config file uses "(def config-map ...)" I would expect everything from that point on to be able to see it.
17:47Raynessproc: I recommend just putting the raw map in the file and then doing (def config (read-string (slurp "yourconfigfile.clj")))
17:52sprocRaynes: Thanks! That works.
17:52wingy_i love lynda courses
17:53wingy_i reask my previos question: if i change a state in a ref/atom/agent, could the previous state still be retrieved or is it "lost" since i have no reference to it?
18:09AWizzArdwingy_: the previous state is lost.
18:13wingy_AWizzArd: aight
18:21haspakerIs anyone here familiar with SublimeREPL?
18:24dnolenhaspaker: I have used it in the past for ClojureScript
18:25haspakerdnolen: Do you know how to update it so the changes I have made in the main document takes effect?
18:26haspakerSo that I don't have to restart it.
18:26haspakerI could use "(use ____ :reload-all)", but that is quite cumbersome
18:27dnolenhaspaker: nope, Sublimer
18:27dnolenhaspaker: SublimeREPL is not an optimal Clojure dev env in my experience.
18:27dnolenhaspaker: works for simple stuff only.
18:28haspakerYeah, seems so
18:28dnolenhaspaker: could of course be improved, compile-file is really the critical missing bit.
18:28dnolenhaspaker: auto recompiling on save is not desirable IMO
18:29haspakerI just want something simple but effectiva
18:29haspaker*effective
18:29haspakerGuess I'll have to go back to Eclipse and CounterClockwise
18:29dnolenhaspaker: or you could submit a patch for compile-file.
18:30devn(Math/round 10.5) => 11, (defn guess-a-number [] (Math/round (+ @a-num @another-num))) => Exception
18:30haspakerDon't know how to do that, unfortunately
18:30devnwat?
18:31dnolen,@1
18:32devndnolen: these are atoms
18:33dnolendevn: is that CLJS?
18:33devndnolen: no, i was asking for a friend who apparently has this problem, but i dont
18:33devnso im not sure what his issue is
18:33devni also dont know which clj version so hmm
18:34dnolen,(Math/round (+ 1 2))
18:34dnolendevn: has nothing to do w/ atoms, will blow up on that too.
18:53scottjsjl: ritz gives you line numbers for code entered at repl.
19:17sauahey, could anyone explain what i'm not understanding about this: https://gist.github.com/3119100
19:20gfrederickssaua: I assume your missing paren on line 4 has nothing to do with it?
19:20gfredericksah I know what it is
19:21gfredericksseems like every day somebody comes in here confused about ->
19:21gfredericks&(clojure.walk/macroexpand-all '(-> "two words" #(clojure.string/split % #" ") last))
19:21lazybot⇒ (last (fn* "two words" [p1__73668#] (clojure.string/split p1__73668# #" ")))
19:21cshellwhat's the clojure equivalent of instance of? satifies?
19:21gfredericks&(doc instance?)
19:21lazybot⇒ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
19:22gfredericks&(doc satisfies?)
19:22lazybot⇒ "([protocol x]); Returns true if x satisfies the protocol"
19:22cshellawesome, thanks
19:22tomojsaua: (-> "two words" (clojure.string/split #" ") last)
19:23tomojif you actually want a fn for some reason you need (-> "two words" (#(clojure.string/split % #" ")) last)
19:23clintmis fetching the maven index with 'lein search xx' the first time broken for everyone or am I doing something wrong?
19:23sauai see. thanks
19:23gfredericksclintm: I have almost nearly never got `lein search` to do anything useful :(
19:23sauai think i understand -> now
19:23gfrederickssaua: it's syntactic
19:24clintmgfredericks: seems to work ok for me - though I'm new to this. this is lein2, btw.
19:24gfredericksoh I'm afraid of lein2
19:24clintmgfredericks: err, it did, i guess.
19:25clintmhrm - maybe if I delete the self-install jar and rerun lein upgrade
19:25gfredericks&(doc ->)
19:25lazybot⇒ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
19:27tomojI'd think e.g. (-> foo ((fn [{:keys [bar baz]}] ...)) ...) should be useful but I don't remember doing that much..
19:29gfredericksthat's a lot of punctation
19:39wingy_yeah lein search is not as powerful as npm search
19:40technomancyjust needs a few tweaks to the query analyzer: https://github.com/technomancy/leiningen/issues/243
19:40technomancyany takers?
19:45cshellwow, i just figured out the idiomatic way to use protocols - I was using them like java interfaces with new records for implementations
19:47technomancythe best way to use protocols is to implement Clojure-in-Clojure
19:47cshellI agree - it's just taking some time :)
19:47cshellto break the java habits
19:48technomancyI mean there aren't very many other sensible uses for them
19:49cshellI wasn't taking advantage of the fact that the first arg could be bound to an existing type - I was creating a new record which implemented the protocol and then took existing types as secon arguments
19:55technomancyany reason you're not using multimethods?
19:59cshellhmmm
19:59cshellI'm using only single, type based dispatch
20:04technomancymultimethods are pretty great at that =)
20:06wingy_now i get why Java is so bloated
20:07pppppaulJava has gas
20:12wingy_ok the only thing so far great is the code completion and auto doc in Eclipse IDE
20:13pppppaulemacs all the way
20:15wingy_pppppaul: even for java?
20:15pppppaulum
20:15pppppaulno
20:15pppppauljava isn't meant to be programmed by hand
20:15wingy_:)
20:17wingy_im going through java just to be a better clj progrmamer
20:17wingy_programmer
20:17wingy_quite a lot of fun
20:17wingy_but clojure is the way to code .. no bullshit
20:17pppppaulindeed
20:18pppppaulcan actually code without an editor
20:18wingy_i mean are we meant to write code or write class hierachies
20:18wingy_yeah but maybe that is not fun?
20:19wingy_editor helps you with the parens
20:20pppppaulparens in clojure can get hairy
20:21pppppaulit's really not as big of a deal as other synatxes
20:21technomancynothing beats a magnetized needle and a steady hand
20:21wingy_jezz java+eclipse is so the 90s
20:22wingy_i doubt they can see anything beyond their keyboard
20:22wingy_it's such an innovation killer
20:29wingy_eclipse is bloated, java is bloated. it's a bloat culture :)
20:32kreig1awoo
20:32kreig1is there a seperate clojurescript channel now?
20:32wingy_kreig1: yes
20:37xumingmingvI have seen the usage of :private metadata in clojure.core, why not just use def- ?
20:42gfredericksdoes that exist in 1.4?
20:42gfredericksno apparently not
20:48wingy_gfredericks: you mean exists in 1.5?
20:49gfredericksnot that I know of
20:58wingy_emacs is the best editor for clojure?
20:59wingy_is it worth learning emacs although i think i will switch to light table next year?
21:03Frozenlo`wingy_: Yes.
21:03Frozenlo`You might end up doing more than just clojure in emacs :)
21:03Frozenlo`Like... oh I don't know... EVERYTHING
21:05gfrederickswhen will light table get org-mode support?
21:05Frozenlo`Let's implement Emacs in light table!
21:06kreig1haha
21:07kreig1emacs + slime is alright
21:07kreig1its what I live in basically
21:07gfredericks&(let [things ["ruby" "clojure" "java" "erlang" "python" "brainfuck"]] (format "Let's implement %s in %s!" (rand-nth things) (rand-nth things)))
21:07lazybot⇒ "Let's implement clojure in clojure!"
21:07gfrederickslazybot: you said it!
21:08wingy_Yo Dawg. I heard you like editing code. So we put an editor in your editor so you can edit while you edit
21:10pipelineclojure-in-clojure would be hilarious if only to see the author run rings around himself for java interop
21:10pipelinelike pypy's pain with c modules, only more complicated
21:11gfrederickswouldn't it just emit bytecode?
21:20wingy_the only way to run a static method with no args is: (. Runtime getRuntime) ?
21:20wingy_since (Runtime/getRuntime) is trying to get the static field
21:23gfredericksthat doesn't sound right
21:23gfredericks(Runtime/getRuntime) works for me
21:24wingy_oh
21:24wingy_my ba
21:24wingy_d
21:24wingy_i forgot to wrap it
21:25wingy_(.totalMemory Runtime/getRuntime) -> (.totalMemory (Runtime/getRuntime)) :D
21:26wingy_i strongly advice beginners to learn Java .. you know how JVM works and many Java APIs that is useful in your clj app
21:26sprocI'm putting Oracle's ojdbc.jar on the class path and then doing a (Class/forName "oracle.jdbc.OracleDriver") in my program and it is throwing a ClassNotFoundException. Why?
21:28sprocNevermind, I found something on Google; it seems Clojure uses a different classloader.
21:30evildaemonHow do I deal with binary files in clojure?
21:30sprocCarefully.
21:31evildaemonsproc: I think that's always a condition when doing operations on bins.
21:31gfredericksevildaemon: at worst, the same way you'd do it in java
21:31evildaemongfredericks: Okay.
21:31sprocAnyone know the name of Clojure's classloader?
21:31gfredericksevildaemon: clojure.java.io might have stuff
21:42xeqisproc: DynamicClassLoader
21:43sprocI ended up having to do (clojure.lang.RT/loadClassForName "oracle.jdbc.OracleDriver")
21:43sprocDynamicClassLoader doesn't include a forName() method.
21:44sprocErr, of course it doesn't
21:49gfredericksclojure projects involve a lot of namespacing mechanisms; github username, maven group name, clojure namespace, git branch...
21:50gfredericksI guess that doesn't really have anything to do with clojure in particular