#clojure logs

2012-07-22

00:00rlbcan't help you there either -- I haven't looked at how clojure compiles to the JVM much at all.
00:00mkwhy doesn't (clojure.string/split ...) auto-require clojure.string, as java.util.Map would "auto-import" Map?
00:00rlbMight want to look here: http://clojure.org/compilation
00:00mkrlb: thanks for the link
00:07amalloymk: a function is a class, inside the package its namespace represents
00:07amalloy&(class inc)
00:07lazybot⇒ clojure.core$inc
00:08mkah, I see
00:09amalloywell, more properly i suppose a function is an instance of a class; each (fn ...) declaration compiles one class, which may be instantiated multiple times. for example (let [adder (fn [x] (fn inner [y] (+ x y)))] [(adder 1) (adder 2)])
00:09amalloythere a single instance of the 'adder class is created, and two instances of the 'inner class are created
00:09mkis the inner bound to any namespace?
00:10amalloyno, it's anonymous
00:10amalloyit happens to be within one because it has to live in a package to exist
00:10amalloy&(let [adder (fn [x] (fn inner [y] (+ x y)))] (class (adder 1)))
00:10lazybot⇒ sandbox81632$eval84433$adder__84434$inner__84435
00:11mkthat makes sense
00:12mkif I create many functions in clojure at runtime, will Java code see them?
00:18amalloythat question is too ill-defined to answer
00:22mkI might be confused. Suppose you create a lib in clojure, and import it from java code. The lib modifies one of its classes. Does the java code see this?
00:23amalloyit doesn't modify one of its classes
00:23amalloyclasses are not mutable, in java or clojure
00:23mkI'm basically wondering about how code knows about other code on the jvm
00:24mkcan a class not be replaced by another class of the same name using clojure?
00:36ro_stso it looks like clojurescript doesn't support vars of fns at all?
00:38ro_stas soon as i have #'ns-or-alias/fn-name i get "WARNING: Use of undeclared Var" when compiling and TypeError: Cannot call method 'call' of undefined on "ns-or-alias.var$.call( null, ns-or-alias/fn-name )"
03:49AtKaaZthis question was bothering me in my sleep: is the only way to add/remove/modify clojure code via repl ?
03:51AtKaaZif I had a clojure program that wanted to create another program dynamically it would have to paste that program to the repl somehow ? or there's another way?
03:57ivanAtKaaZ: no, anything can load new code (via require I guess)
04:00AtKaaZbut say for example I've a String(input by user) which contains clojure code, can I simply append that code to a function at runtime or something like that ?
04:01AtKaaZcome to think of it, that's quite like what 4clojure.com is doing
04:02AtKaaZbut I don't know how they're doing it, I'm hoping not by pasting that to the repl somehow
04:03AtKaaZivan, with require it seems the code must already exist somehow "The require function loads Clojure libraries."
04:04ivan(eval (read-string "(+ 1 1)"))
04:05ivanREPL = read eval print loop; you'll find the (eval call in repl.clj :)
04:06AtKaaZwow that's quite epic I was able to define a function with that and use it later
04:06ivaner, that other file
04:07AtKaaZso that's how to write dynamic code?
04:08ivanyeah, but there is generally no need for eval
04:08AtKaaZjust read-string then?
04:09AtKaaZthis is quite awesome
04:09ivanwell, read-string will load Clojure data structures but not call anything (excl. the "=(" evil)
04:10AtKaaZhow can i see the source code for read-string, I did (source read-string)
04:11ivanthe (clojure.lang.RT/readString s) means it's implemented in RT.java
04:12AtKaaZif it were in a .clj I would be able to see the clojure code?
04:12AtKaaZvia the source
04:12ivanyes
04:12AtKaaZcool than, thanks for this info
04:13ivanyou were looking at the Clojure source though; defn read-string is in core.clj
04:14aibis there a way to get the definition of a macro?
04:14AtKaaZoh that [s] meant this is the source code [s] (clojure.lang.RT/readString s)
04:14yy\o/
04:15AtKaaZThe source function, in the clojure.repl library, uses this metadata to retrieve the source code for a given function or macro.
04:16AtKaaZ,(source reverse)
04:16clojurebotSource not found
04:17ivanAtKaaZ: the [s] is just the argument list for the function
04:17aibAtKaaZ: thanks
04:18AtKaaZyeah I was about to say that, as I just noticed for reverse
04:18plainflavoredhow difficult do you think it would be to implement clojure in python?
04:18AtKaaZ [coll] (reduce1 conj () coll)
04:19AtKaaZhttps://github.com/eigenhombre/PyClojure/
04:19plainflavoredrad! thank you
04:19AtKaaZactually, they say: clojure-py project is further along
04:20AtKaaZthis: https://github.com/halgari/clojure-py
04:24aib,(#(+ %1 %2) 21 21)
04:24clojurebot42
04:29mikemwhere can I find clojure.contrib.io/read-lines today?
04:31mikemor it's been deprecated outright?
04:46AtKaaZmikem: http://freegeek.in/blog/2011/06/10-clojure-one-liners/ scroll down to 4. Read a File
04:48mikemAtKaaZ: yep, i saw that. thanks :-)
04:51mikembut next question... why doesn't this work? (with-open [...] (first (line-seq ...))) ;=> "{:one 1, :two 2}", but (read-line (with-open [...] (first (line-seq ...)))) yields a blank java.lang.Symbol
04:52RaynesBecause that is something completely entirely utterly different from what the other thing does.
04:52RaynesAre you trying to read the string into a map, mikem?
04:52Raynes&(read-string "{:foo 1 :bar 2}")
04:52mikemRaynes: yes
04:52lazybot⇒ {:foo 1, :bar 2}
04:52Raynesread-string is what you want.
04:53mikemoops, that's a typo. I am using read-string, not read-line
04:53RaynesNote that you shouldn't use read-string on anything you get from a user, as that basically allows them to eval any code in your app. You can do (binding [*read-eval* false] (read-string ..)) if that is the case.
04:53mikemthe issue is with read-string returning a blank symbol
04:53RaynesWhat is a 'blank symbol'?
04:54mikemat the repl I see a blank line as the return value... when I wrap read-string in a (class ...) I see clojure.lang.Symbol
04:55mikemif i pass a string literal to read-string it works, but on an instance of java.lang.String it doesn't
04:55RaynesA string literal is a java.lang.String.
04:56hiredmanwhat do you think a string literal is?
04:56mikemheh you're right
04:56RaynesAnd that doesn't make any sense. What does the map look like?
04:56RaynesThe actual map you're trying to read?
04:56mikem"{:text \"hello\", :id 10}"
04:57RaynesDo this for me: (prn (read-string (with-open [..] (first (line-seq ..))))
05:00mikemwhat's the preferred pastebin for Clojure code?
05:00Rayneshttps://www.refheap.com is generally preferred these days, I think.
05:00RaynesI totally didn't write it.
05:00AtKaaZlol
05:00mikemhaha
05:01mikemRaynes: https://www.refheap.com/paste/3729
05:02Raynesmikem: Sec.
05:04Raynesmikem: Yeah, I'm totally lost. This shouldn't be happening.
05:04Raynesmikem: Perhaps restart the repl? Maybe read-string got redefined somehow or something.
05:04RaynesBeyond that, I can't see any issues.
05:05mikemwere there any known issues recently with read-string?
05:05RaynesI can't reproduce what you're seeing.
05:06RaynesI don't know of any version of Clojure that had a read-string that was broken like this.
05:06Raynesantares_: Hello there, good sir.
05:06antares_hey Raynes
05:06Raynesantares_: Sorry I haven't had a chance to do what you asked in monger and friends.
05:06RaynesMight start poking around tomorrow.
05:06antares_that's ok
05:06antares_thanks!
05:07RaynesWill ping you with any findings.
05:07mikemRaynes: so when you try to read-string something that comes out of line-seq, everything works?
05:07Raynesmikem: Yup.
05:07mikemwhich version of Clojure are you using?
05:07Raynes1.4
05:07RaynesBut this should work in any version.
05:07RaynesDid you try restarting the repl?
05:09mikemRaynes: yeah, still broken. I'm also using Clojure 1.4.0. Besides, this doesn't really strike me as something that would break
05:10AtKaaZthat works for me too
05:10AtKaaZon windows
05:11AtKaaZwith eclipse and ccw
05:13AtKaaZhow can I know what version of clojure I'm using from repl ?
05:15AtKaaZ,(clojure-version)
05:15clojurebot"1.4.0-master-SNAPSHOT"
05:15AtKaaZI'm on 1.3.0
05:17mikemok, mystery solved... turns out there were some null bytes (or other junk) before the first { character in the file somehow (I wrote it with clojure earlier). These didn't show up when catting the file, but were glaring at me in vim. All's working now
05:19AtKaaZhow could you guard against that in the future?
05:19AtKaaZ,*clojure-version*
05:19clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
05:27aib"The nice thing about vectors is you don’t have to do anything special to use them as data as you do with lists." -- is the "special thing" mentioned here quoting?
05:28mikemaib: yeah, probably. the [] reader literals for vectors save you the trouble
05:46AtKaaZmikem, I was able to reproduce your example with null char in front, and in eclipse I am able to see the null char as a rectangle char but i can't paste it here, I figured you couldn't see it on your console
05:52AtKaaZscreenie: http://s18.postimage.org/tlyj9l3qv/null_char.png
05:52mikemAtKaaZ: i'm not sure which character it was. In vim it appeared as ^@ and in hexedit it was 00.
05:52AtKaaZyeah that's the one I used too
05:54AtKaaZwhat I was trying to say is that it somehow didn't visually show on your console and thus made it harder to realize
09:40jsnikeristechnomancy: Are you there?
09:49augustltechnomancy: ref environment variables for credentials to repos - doesn't it make sense to support an unencrypted credentials.clj too in that case?
09:50augustlif you can store unencrypted passwords in your ~/.bashrc or whatever, you might as well support reading out credentials.clj without a .pgp too imo :)
11:07cshellhas anyone had any problems using the environ.core library in 1.4?
11:58cshelldid something change with lein 2 with regards to the lein deps command?
12:03jsnikeriscshell: I think it uses Pomegranate now.
12:18jst25i'm trying to use the ClojureScript One animation libary in a seperate clojurescript project. I keep getting an " No protocol method IPosition.position defined for type object: [object Object] " error, when there definitely is a prrotocal method defined for the type I'm passing it, anyone know what might be causing this? could it be something to do with different CLJS versions?
12:18jst25I'll try to extract a simpler test case, just checking first if anyone's ran into things like this, it's driving me nuts
12:21mkjst25: a few google results for "No protocol method * defined for type object: [object Object]"
12:22mkjst25: do any of those seem on track?
12:23mkhttp://clojure.org/books is this page blank for just me?
12:24jsnikerismk: it's not blank for me
12:25mkthere are books visible?
12:25jst25mk: thanks, checking those out now. I've seen a few before but I didn't know you could use wildcards in quoted google strings
12:25jst25mk: and i'm also not seeing any books
12:27mkjst25: yeah, I've learned that it's a really useful trick for errors with variable text in the middle
12:27mkI wonder why the books aren't showing...
12:27mkoh, adblock
12:33ambrosebsI just pushed another alpha of Typed Clojure, should be fun to toy around with if you're so inclined
12:36mkis there an overview somewhere of what the various clojure books are like?
12:38jst25mk: I think I've seen people discussing it here in irc before
12:38jst25searching the logs might be useful
12:40jst25i can't seem to find the specific discussion i was thinking of right now though sorry
12:40mkyeah, though I was hoping for something more... directly comparing them
12:48harjaDoes someone have experience with quil? I have this http://pastebin.com/gpQ9hYTN
12:48harjaWhat am I doing wrong?
12:55mkharja: do you want doseq?
12:55mkhttp://clojuredocs.org/clojure_core/clojure.core/doseq
12:58harjamk: Ah, fantastic :)
12:58harjaI tried do inside for but it did not do the same thing
12:58harjaI'm very new to clojure so this is all guesswork for me atm
12:59mkthe cheatsheet is helpful http://clojure.org/cheatsheet
12:59mkat the bottom of "for" there's a see also
12:59rlbharja: "for" is lazy, so if you don't use the result, nothing may happen.
13:00harjarlb: okay, that makes sense
13:00rlband even if you do use the result, itm may not happen when you want it to.
13:00harjaso basically when I want to run any seqs, lists or anything, I use do
13:00gfredericksno doseq
13:00harjayes, do* :)
13:00harjaso for seqs it's doseq
13:00gfredericksbut yeah, 'do' normally applies to side effects
13:00harjaif it's just plain exprs, its o
13:01harjado
13:01rlbharja: there's also doall.
13:01rlb(if you want to force the evaluation and keep the result)
13:02gfredericksand dorun
13:02gfredericksfor forcing without keeping
13:02harjadorun, doseq, doall seems to be my options in the cheat sheet
13:03harjaare vectors and lists freely exchangeable as parameter lists and such?
13:03harjaI've heard that vectors are to be used in clojure instead of pure lists
13:04gfredericks&(fn (a b) (+ a b))
13:04lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
13:04rlbharja: depends on what you mean -- syntax-wise clojure requires vector for declarations, i.e. (fn [] ...)
13:04rlbi.e. they're not generally interchangable wrt syntax.
13:04rlbfn/let/doseq/etc.
13:04harjarlb: yeah, that I know. But for example if I have (apply fn stuff) and stuff can be either a vector or a list etc
13:05gfredericksyeah that's the seq interface
13:05harjayes, that's what I was looking for
13:05gfredericksnormally anything seqable can go there
13:05gfredericks,(apply str "hooha")
13:05clojurebot"hooha"
13:06rlb(including maps, sets, etc.)
13:06harjayeah, that's kind of obvious given that info :)
13:06harjawell, back to learning. so far this has been quite a fun stuff
13:06harjathanks for your answers
13:06mkI guess doseq is like -> ?
13:07gfredericksno
13:07mkin that it pushes the args into a single form
13:08gfredericksdoseq doesn't do syntactic manipulation like that. it iterates through your seq and evals expressions on each item
13:09mkright, no threading, but it does push arguments into a form
13:09gfredericks,(macroexpand '(doseq [x [1 2 3]] (print x) (print x "foo")))
13:09clojurebot(loop* [seq_59 (clojure.core/seq [1 2 3]) chunk_60 nil count_61 ...] (if (clojure.core/< i_62 count_61) (clojure.core/let [x (.nth chunk_60 i_62)] (do (print x) (print x "foo")) (recur seq_59 chunk_60 count_61 (clojure.core/unchecked-inc i_62))) (clojure.core/when-let [seq_59 (clojure.core/seq seq_59)] (if (clojure.core/chunked-seq? seq_59) (clojure.core/let [c__2616__auto__ (clojure.core/chunk-fi...
13:10gfredericksmk: I'm not really sure what you mean by that
13:11mkperhaps it's not like that... what I mean is:
13:11mk,(doseq [x 1] (prn x))
13:11clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
13:11gfredericks,(macroexpand-1 '(doseq [x [1 2 3]] (print x) (print x "foo")))
13:11clojurebot(clojure.core/loop [seq_129 (clojure.core/seq [1 2 3]) chunk_130 nil count_131 ...] (if (clojure.core/< i_132 count_131) (clojure.core/let [x (.nth chunk_130 i_132)] (do (print x) (print x "foo")) (recur seq_129 chunk_130 count_131 (clojure.core/unchecked-inc i_132))) (clojure.core/when-let [seq_129 (clojure.core/seq seq_129)] (if (clojure.core/chunked-seq? seq_129) (clojure.core/let [c__2616__aut...
13:12mk,(doseq [x [1]] (prn x))
13:12clojurebot1
13:12mk,(-> 1 (prn))
13:12clojurebot1
13:13gfredericksmk: -> does that at the syntactic level; doseq doesn't, or else it could only work with seq literals
13:14gfredericksso I think anything you're thinking of applies equally well to let
13:15mkwell what I'm thinking is that the two are similar because they (ultimately) push arguments into functions
13:16mk-> keeps on pushing, while doseq pushes different arguments
13:16mkand of course doseq requires a binding
13:18mkthe form in the pastebin was (for [[x y] [[10 10] [20 20] [30 30] [40 40]]] (rect x y 100 100))
13:19mkI was wondering if there was something like (~> [[10 10][20 20][30 30][40 40]] (rect 100 100) )
13:20mksince this would get rid of the binding, which seems a bit messy
13:20gfrederickswill in that particular case x and y are always the same, so no reason to have two names
13:21gfredericks(for [z [10 20 30 40]] (rect z z 100 100))
13:21mkright, I was just pasting the example, but assume they differ, but must be pushed into that standard first-parameter slot
13:23mk(for> [10 20 30 40] (square 0 5))
13:24mkI'm pretty sure -> and ->> are the only ones with that non-bound format, though...
13:27gfredericksthat's because they work at the syntactic level; for/doseq/etc don't mess with your form at all
13:27gfredericksso I think these kinds of comparisons are likely only going to confuse anybody
13:33mkdon't know about that. They're different, but ultimately they're both for pushing parameters into functions (rather than, say, generating a seq)
13:33gfredericksdoes let push parameters into functions?
13:35mkI'm not sure, but I'm thinking of it more as something like a definition, or shorthand, or a rule of replacement
13:37gfredericksthey're not remotely interchangeable; you can do things with -> that wouldn't compile with doseq
13:38gfredericks,(-> 7 (/ 0) (try (catch Exception e :haha)) (assert))
13:38clojurebotgfredericks: It's greek to me.
13:38gfrederickswat
13:38gfredericks&(-> 7 (/ 0) (try (catch Exception e :haha)) (assert))
13:38lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
13:38eggsbyhuh, catch is bad?
13:38clojurebotPardon?
13:38gfredericksin any case, there's nothing comparable to that with doseq
13:39mkeggsby: the bot is scared of it for security reasons
13:39harjawhat would be the clojure's idiomatic way of taking a sequence of integers and producing a list of tuples s.t. for each element e in seq the corresponding tuple is (e (next-in-seq-from e)). I've done this with (partition 2 (interleave foo (drop 1 foo))) is it ok?
13:40gfredericks&(partition 2 1 (range 10))
13:40lazybot⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9))
13:40gfredericksharja: ^
13:40mkgfredericks: yeah, I see what you're saying. I guess I'm talking about how I'm categorizing them according to when you'd need to think of using them
13:40harjagfredericks: yeah, just like that
13:40harjaWhat if I want to wrap that around
13:40harjaso the last element would be (9 0)
13:41gfredericksthere'd be a few different ways to hack that together
13:41gfrederickseasiest is ##(let [coll (range 10)] (concat (partition 2 1 coll) [(last coll) (first coll)]))
13:41lazybot⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) 9 0)
13:41mkcreate a loopy range
13:41gfredericksno not quite
13:42gfredericksmk: that's cycle
13:42gfredericksbut that would work too...
13:42gfredericks&(let [coll (range 10)] (take (count coll) (partition 2 1 (cycle coll))))
13:42lazybot⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) (9 0))
13:42harjathat seems good. I came up with that first one
13:43gfredericksprobably the only way to do it with one pass through the seq would be something complex with lazyseq
13:43gfredericksnot worth it unless your coll is hugegantic
13:43harjayeah, I have a collection of 30 to 50 elements for now
13:44harjaso performance is not really an issue here :)
13:44gfredericksthat should be enough for anybody
13:46mkis there one for spinning a seq around? (1 2 3) -> (2 3 1)
13:46mkor is that impossible due to infinity?
13:48gfredericksit's okay for a seq function to hang on infinite seqs
13:48gfredericks&(last (range))
13:48lazybotExecution Timed Out!
13:48gfrederickslazybot: botsnack
13:48lazybotgfredericks: Thanks! Om nom nom!!
13:48gfredericksI wonder how far he got
13:50mknot far enough
13:53harjahow to include for example the combinatorics package in clojure.math.combinatorics to my leiningen 2.0 project?
13:53harjahow do I know what the version number should be
13:53harjain the project.clj file
13:54jasonjcknharja: try [org.clojure/math.combinatorics "0.0.4-SNAPSHOT"]
13:54jasonjcknyou may need to use "0.0.3"
13:54harjajasonjckn: Thanks, where did the version number come from?
13:55jasonjckn0.0.4-SNAPSHOT i got from the pom.xml file on the github project https://github.com/clojure/math.combinatorics/blob/master/pom.xml
13:55jasonjckn0.0.3 from maven repository http://mvnrepository.com/artifact/org.clojure/math.combinatorics
13:55harjaokay
13:57mk(??? [a (mod a 3] (range 3)) -> ((0 1)(1 2)(2 0)) ?
13:57mkplus a paren. Is there anything that does that?
14:10TimMcmk: Not sure precisely what you want, but you might look at partition/partition-all and cycle.
14:11mkTimMc: I was wondering about other ways of implementing the functions given above
14:11TimMc&(let [m 3] (partition 2 1 [0] (range m)))
14:11lazybot⇒ ((0 1) (1 2) (2 0))
14:13mkwell that was easy
14:13joegallo_mk: not like that exactly...
14:13joegallo_ah, woops, failed to scroll down :)
14:13joegallo_nevermind
14:17mkthat's probably exactly a case that the pad is meant for, though it's not very obvious
14:19mkare (ns-...) all subsets of ns-map?
14:22hyPiRionUnexpected. I didn't know clojure allowed single-quotes in variable-names.
14:23hyPiRion&(dec' 1.01)
14:23lazybot⇒ 0.010000000000000009
14:24ebaxtanyone using noir here that can answer a quick question about middleware and noir.util.test?
14:25mkebaxt: you're in the right place, and if you aren't you'll usually find out by just asking :)
14:29ebaxtmk: well, I'm basically wondering if it's possible to enable middleware when using the send-request-map helper in noir?
14:30ebaxtmk: I'm using the middleware described here: https://groups.google.com/forum/#!topic/clj-noir/INqvBo6oXIA/discussion but since it's not enabled when testing with send-request-map I'm thinking it's not adding much value :)
15:04mk,(var? *ns*)
15:04clojurebotfalse
15:06mkis *ns* a var, or an atom, or?
15:07cark,(var? #'*ns*)
15:07clojurebottrue
15:07carkthere is a *ns* var
15:07carkwhen you use *ns* you get trhe value bound to this var
15:09AWizzArdThe four chars ‘*ns*’ make up a symbol.
15:09carkalso yes
15:09mkwhy isn't it an atom?
15:10AWizzArdYou can use the special form ‘var’ on a symbol, to resolve it to a var. cark used the reader macro #' instead of var.
15:10carka symbol is an atom in the lisp sense, but not in the clojure sense
15:10AWizzArdThis var is dynamic, and resolves to an instance of the class Namespace.
15:10mkdon't know what an atom is in other lisps
15:11AWizzArdIn Common Lisp everything that is not a list is an “atom”.
15:11carkvars are references just like atoms, but they have different properties
15:11mkI'm wondering why *ns* is a var, if vars are intended to not be changed
15:11AWizzArdVars are just another level of indirection.
15:12AWizzArdBecause Clojure is a dynamic language, it will not link directly to the objects, but instead to vars.
15:12mkI thought vars were the first level of indirection
15:12AWizzArdAt runtime those will be resolved to lookup the “real” reference to the object in RAM.
15:12mkright, much like in javascript
15:13AWizzArdThat allows you to first define a function foo, then later bar which calls foo. If you now change foo again, bar will automagically call the new foo.
15:13AWizzArdThis is because occurences of “foo” are not replaced by a direct jump to the real function, but instead with a lookup of the Var.
15:14mkI'm reading, though, that if you plan to change the value, you should not use a var. But *ns* can change all of the time, so what am I missing?
15:15carki think that's because dynamic vars have dynamic (!) scope
15:15carkby binding *ns* to a namespace, you're in the context of this namespace
15:16carkor the implementor is really, i never had to do that
15:16mkwhat does being in a context mean?
15:16AWizzArd*ns* can only change in a given thread. There are no concurrency problems with it.
15:16carkwell it only means that *ns* has a value for the length of the call chain inside the binding form
15:17cark(binding [*ns* some-namespace] (do-stuff))
15:17lancerois there something in the repl like *print-length* that works for strings?
15:18mkand if it were an atom, it wouldn't get set back to the right value when it came out of the binding?
15:18antares_lancero: clojure.core/count works for strings
15:19carkmk : mhh i think that could be done, but yes, binding applies to vars
15:19lanceroantares_: not sure if I understand. I want something that will limit all strings output to the repl.
15:19antares_lancero: ah. I don't think there is way to do that but maybe clojure.repl has something.
15:19carklancero: maybe have a look at pprint, there might be something along those lines in there
15:21mklancero: you might look at *out*, and see if you can wrap System/out
15:22carkmk : awizzard make a good point, with atoms, you couldn't do a my-binding form, as the value might change in another thread
15:23mkwhere is *ns* stored then? in the namespace? in the thread?
15:24AWizzArdYou can see a dynamic var as: one atom per thread
15:24carki don't know the implementation details, but sementically one could see it as each thread having its own copy of it
15:24AWizzArdEach thread has its own ‘atom’, its Var.
15:25mkso dynamic = *...* = encapsulated to the thread?
15:25AWizzArdyup
15:26mkI see
15:26mkcark, AWizzArd: thanks
15:26mkare (ns-...) all subsets of ns-map?
15:27carki don't understand your question
15:27lanceromk: I don't think that has any impact on the repl. I mean if some function returns a huge string, it'll get printed.
15:28mkdoes ns-map return everything that ns-name, ns-publics, etc. return?
15:29carki don't think so, it only return a name to object map
15:29carkns-publics must be looking into each of these i think
15:30mklancero: I thought perhaps the repl used *out* for printing
15:31carklancero: maybe you could change print-method for strings ... tho this is a bit heavy handed
15:32lancerohmm... ok. well is there any other way prevent slime/emacs from becoming unresponsive when big strings are printed?
15:33carkprint smaller string ! =)
15:33carkstrings*
15:33mklancero: don't print big strings? perhaps you could wrap output in some sort of recursively truncating function
15:33AWizzArdlancero: You can try to open the task manager and kill the java.exe
15:34carkor don't use emacs !
15:34lanceroAWizzArd: yeah! that's what I'm trying to avoid :)
15:34carkmhh tho i don't know what other editor is good with clojure these days
15:34mklancero: what does the output look like? just strings in a list?
15:36lanceromk: if i was carefull enough to notice each time that it might happen i'd just send it to some output file
15:38lancerohmm... but there's got to be some way to tell the repl to just no print out results at all?
15:39cark,(do (+ 3 2) nil)
15:39clojurebotnil
15:50HeadlessClownare lein 2.x dependencies still supposed to be written to project/libs/ ?
15:50ibdknoxHeadlessClown: no
15:51HeadlessClownwhere art thou?
15:51ibdknoxit adds them directly from ~/.m2
15:52HeadlessClownwell now.. there's the little fellas
15:53HeadlessClownthanks!
15:55mkis there a way to pull apart thread data (the stack etc.) from the process? For example, if I have an infinite loop, can I pause it, let the thread that was executing it die, and then later create a new thread that picks up where the last left off?
15:56arohnermk: not really. You could pause the thread using the debugger, but you can't create a new thread that's a "copy" of it
15:56arohnerthere's no call-cc
15:59mkhmm. Why not, and is there anything similar?
16:00seancorfieldHeadlessClown: if you need the JARs copied from the classpath to somewhere concrete for any specific reason, i have a lein plugin that copies them to a folder inside the target/ folder... but since that is considered a weird edge case, i have not published it anywhere yet...
16:00mkperhaps this is because threads use the java stack and it can't be ... saved? I'm not thinking of cloning the stack, so much as just having it as data
16:01carki think there would be security issues if the jvm would allow that
16:02carkwhat do you need tht stack data for ?
16:02mkI don't think so, because a naked thread picking up all the data of a dead thread is identical to a thread being paused, and picking itself up again
16:04carka thread is some kind of a state machine, maybe you could make one, then move its state from one thread to the other
16:04mkcark: I was thinking of some sort of pausible repl-initiated task
16:07carkmaybe use an agent as you task, it has state, make it so it proceeds by sending messages to itself, and add a message for pause....get its state and restart it
16:07mkpausable*. I was thinking clojure might have something that allows this, because of binding etc.
16:08mkcark: that seems similar, though I don't think it would work for arbitrary code
16:10carkor make it like trampoline, returning the continuation to your task, and a function to run it, until it's paused. then run that returned function on another thread
16:11carkmanual call with cc
16:11mkwhat's a trampoline?
16:12Bronsa,(doc trampoline)
16:12clojurebot"([f] [f & args]); trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f with supplied args, if any. If f returns a fn, calls that fn with no arguments, and continues to repeat, until the return value is not a fn, then returns that non-fn value. Note that if you want to return a fn as a final value, you must wrap it in some data structure and un...
16:12mkis this new? it's not on the cheatsheet
16:12Bronsa,(-> #'trampoline meta :added)
16:12clojurebot"1.0"
16:13duck1123trampoline isn't that popular, because how often do you need to recurse like that?
16:15mkthe returned function can use closures, right?
16:17duck1123you have to use closures, the fns can't take args
16:17mkseems like you could replace any recursive call with a function return, and trampoline it
16:18duck1123the examples I've seen involved needing to go back and forth between two different fns. Otherwise, why not just invoke the code directly
16:19mkcall stack
16:19carkit's usefull for continuation based stuff, when you have a very long call chain
16:20mkcark: why would you need to trampoline those? just to pause?
16:20carkto avoid stack overflows
16:21mkoh, I see you meant what I meant. I thought you meant a recursive function that called many sub-functions, or something
16:21carki made this little parser combinator, it passes the continuation to each parser for success and for failure
16:22carkso if you're parsing a very long chain of 1 character, that's each time a call, that wouldn't do for a long text
16:23carkthat's where trampoline got usefull for me
16:23carki bet there are plenty other use cases
16:23mkinteresting
16:24cark... if not very efficient =P
16:24carki did this, because with a recursive descent parser i woudl get huge stack traces when i got errors at the bottom of it
16:25carkso i wanted small stack traces, hence continuation based
16:30duck1123how expensive is doall if your sequence is already realized?
16:31cshellis there any way to get lein 2 to put the deps back in lib?
16:32duck1123cshell: if not, lein pom; mvn dependency:gather-dependencies
16:34cshellhow do I tell maven to use version 2.4 of the plugin from the command line? it's using 2.1 and doesn't ahve gather-dependencies
16:34duck1123it might be copy-
16:35cshellyeah i think it looks like it based off the docs
16:35cshellduck1123: thanks! I didn't think about doing it that way
16:35mkduck1123: maybe try it out?
16:36mkwhat happens if I (let [*ns ...] ... ?
16:36mk*ns*
16:37carkyou'll have a local *ns* value in no way related to the *ns* var
16:37mkwill it be used to resolve things?
16:37carknope
16:37mkwhy not
16:38carkbecause it's only a name at that point, the *ns* symbol is "shadowed"
16:39mkif I (let [*out* ...], then the new out is used for technical background things. So why not *ns*?
16:39carkif you want to temorarily bind another value to *ns* use the bonding form
16:39carkis it?
16:39cark,(let [*out* :a] (println "hello"))
16:39clojurebothello
16:39mkdon't know, I might be confusing it
16:39carklooks like it isn't
16:40mkwhat am I thinking of, then?
16:40duck1123you're thinking of binding
16:40cark(binding [*out* :a] (println "hello"))
16:40duck1123let is only for the code lexically in the block
16:40carklooks like clojurebot crashed =P
16:41duck1123,(binding [*out* :a] (println "hello"))
16:41clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.io.Writer>
16:41carkoh forgot the comma !
16:41cark=)
16:42duck1123it's trying to write to :a which is the new value of *out* in the binding block (not just in the top level code
16:43mkso what's the difference between let and binding?
16:43carkso : let is lexically scoped, binding is dynamically scoped
16:43mkI don't think I understand the difference
16:44carklet only works for the text inside those parenthesis around it (let [a value] ...here....)
16:44carkif you call a function (let [a value] (somefunction)), a oes not exist in somefunction
16:44cark*does
16:45cark*ns* is a var, it exists everywhere
16:45mkbut what if that function makes reference to a symbol called a?
16:46carkso (binding [*ns* some-value] (some-function)) : *ns* has value some-value in function some-function
16:46duck1123,(let [a 1 b (fn [] a)] ((juxt let binding) [a 2] (b)))
16:46clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(NO_SOURCE_PATH:0)>
16:46duck1123awww
16:46carkmk : let's try it
16:46duck1123,(let [a 1 b (fn [] a)] (let [a 2] (b)))
16:46clojurebot1
16:47duck1123,(let [a 1 b (fn [] a)] (binding [a 2] (b)))
16:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:47cark,(let [f (fn [] (+ 2 a))] (f))
16:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:47carksee the symbol a does not exist
16:47cark,(let [f (fn [] (+ 2 a))] (let [a 2] (f)))
16:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:47duck1123not dynamic
16:47carkstill does not exist
16:47duck1123this won't work in clojurebot
16:48carkbecause let only works on the lexical scope it encloses
16:48duck1123trying to get around the no def rule
16:49mk,((fn [f] (let [a 1] (f)) (fn [] (a))
16:49clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
16:49mk,((fn [f] (let [a 1] (f)) (fn [] (a)))
16:49clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
16:49mk,((fn [f] (let [a 1] (f)) (fn [] (a)))
16:49clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
16:50mkI give up, I didn't even add another paren that time
16:50mk,((fn [f] (let [a 1] (f)) (fn [] (a))))
16:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:50duck1123stupid sandboxes not letting me do stuff. failed on cljbin as well, http://cljbin.com/paste/500c6722e4b0f700d2d474b5
16:50mk,((fn [f] (binding [a 1] (f)) (fn [] (a))))
16:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:50cark(let [a 1] (f)) <- that's where a is defined
16:50carkoutside of it, you're out of the lexical scope
16:51carkthere is much literature on the web about lexical vs dynamic scope
16:51duck1123cark: if you ever find you want to bash on one of the bots to get something right, you can do it in a query and they'll respond
16:51mkI'm under the impression that (fn [] (a)) should be ok if it is executed where a exists
16:52amalloymk: it has to be compiled to know where to look for a
16:52carkduck1123: i was expecting these errors, making a point for mk
16:52duck1123The point is lexical scope is tha actual text of the code, dynamic scope is all the code of all the fns called
16:52amalloyduck1123: you could do this in the bots, using ##(doc with-local-vars)
16:52lazybot⇒ "Macro ([name-vals-vec & body]); varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set"
16:53duck1123amalloy: good to know.
16:56mkso when a function containing a symbol is compiled, the symbol is just replaced with a reference to whatever it refers to, or?
16:58carki don't know how it works under the hood, but conceptually it looks at frames bottom-up .... first loot at current let, the the let out of it, the the function parameters, and eventually the top-level vars
16:59carkthen* then*
16:59carklooks like my keyboard is really dying =(
17:00mk,((fn [] (a)))
17:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
17:01mkso at compile time? How can I use a symbol that might not be bound to anything?
17:01carkwhat would you use it for ?
17:01mk,((fn [] (*out*)))
17:01clojurebot#<ClassCastException java.lang.ClassCastException: java.io.StringWriter cannot be cast to clojure.lang.IFn>
17:01cark,(name 'a)
17:01clojurebot"a"
17:02cark,(name (quote a))
17:02clojurebot"a"
17:02cark(quote a)
17:02cark,(quote a)
17:02clojurebota
17:02cark,(type (quote a))
17:02clojurebotclojure.lang.Symbol
17:02mkcark: I'm thinking of how print uses the value of *out*
17:03carkwell *out* is not just a symbol, it's a var
17:03amalloymk: *out* is defined in clojure.core. it's not some magic var that gets made up
17:03cark,(type *out*)
17:03clojurebotjava.io.StringWriter
17:04mkwhat if pr was defined before *out* was defined?
17:04amalloywouldn't work
17:04carknothing magic about it, it was defined somthing like this : (def *out* (StringWriter. ....))
17:04amalloybinding gives it a new value, but a var has to be defined/declared to tell functions where to look for the current value
17:04Bronsayou could declare it and define it later
17:04mkwhat if *out* was deleted (or changed) after pr was defined?
17:04amalloymk: try it and see
17:05carkwe did try it (binding [*out* 1] (println "hello")) -> println throws an error
17:05mkdon't know how to delete and don't have a handy repl besides bot
17:06mkcark: that's because pr expects out to be a printwriter, not a number
17:06amalloycark: he wants to destroy the var, not give it a new value
17:06carki don't want ot test that in my repl !
17:07carkns-unmap might do the trick
17:07amalloyi'm not sure, but i think the answer is: you can't do that; the var will refuse to be destroyed if someone has a reference to it
17:07carkbut i guess the reference to the var will keep it alive, and prevent garbage colletion
17:08carkhum i'm pretty sure you can unmap everything
17:08mk,(ns-unmap *ns* '*out*)
17:08clojurebotnil
17:09cark,(println "yoh")
17:09clojurebotyoh
17:10carkbots are not a good playground for this kind of stuff
17:10carkbesides you would need to unmap it from clojure.core
17:12mkso once a var is referenced, it can never be unmapped?
17:12carki don't know
17:13mk*out*
17:13mk,*out*
17:13clojurebot#<StringWriter >
17:13mkI got a repl up and got similar results
17:16mkamalloy is correct it seems
17:17mkif I defn and make reference to foo in function f, (ns-unmap foo) fails until I unmap the function f
17:19RaynesWhy are we talking about destroying vars?
17:19RaynesWhat have they ever done to us?
17:19carkplus they're so cute
17:36cshelldoes anyone know what text editor/repl cemerick uses?
17:36brehauteverything but emacs
17:37RaynesHe uses Eclipse.
17:37RaynesI also got him to use Vim. Not sure if he still does.
17:40cshellah cool, thanks guys
17:41cshellI just spent the afternoon trying to get the leiningen plugin in Intellij to work with 2.0 - but the intellij plugin documentation is horrible and I have no idea where to hook in
17:42cshellfirst time i've been disappointed with jetbrains
17:45tickinghow is one supposed to debug something without line numbers or function names?
17:45ivanClojure provides both
17:46tickingivan, how so? the only thing it spits at me is ClassCastException java.lang.Boolean cannot be cast to clojure.lang.Symbol
17:46tickingand a unusable compiler stack trace
17:46ticking(pst) isn't of much help either
17:47emezesketicking: pastebin?
17:47tickingemezeske, there you go https://gist.github.com/3161113 ^^
17:49emezesketicking: What's this hook.core thing?
17:50ivanwhatever is calling alias is passing a boolean instead of a symbol for the first arg
17:50mkwhy doesn't clojure just map symbols to values? it seems to map symbols to vars, and the value of the var can change
17:50emezesketicking: It looks like maybe it's eval-ing some code; if that's the case, that might explain why there's no line number available maybe?
17:50tickingemezeske main namespace of my app (hook was just a quick thing I came up with not after callback but peter pans arch enemy ^^)
17:50brehautit looks like you need to refer-clojure 'load or change your def
17:51tickingemezeske, no evaling
17:52ivanticking: can you paste your code from hook that does the require?
17:52tickingbrehaut, load is overriden in another napespace
17:53brehautticking: loading a clojure namespace / source file will result in some code being evaled, even if you arent calling 'eval' yourself
17:53tickingivan there you go :) https://gist.github.com/3161129
17:54tickinghere's the entire code of the core file https://gist.github.com/3161132
17:54brehautticking: does hook.image refer-clojure?
17:55tickingbrehaut, hm?
17:55tickinghttps://gist.github.com/3161135
17:58brehautoh, theres an error and a warning. the warning is that you are shadowing clojure.core/load in your hook.image namespace. you can make that warning go away by telling clojure not to implicitly import 'load from clojure.core with a :refer-clojure definition in your hook.image namespace
17:59tickingbrehaut, ah thanks for that ^^, yeah the error is the problem
18:04tickingso I assume you guys gave up as well ;)
18:05brehautticking: you might have to do a binary chop and comment out half the forms to find the offender if nobody can work it out by observation alone
18:05tickingbrehaut, thats rediculous, why isn't the compiler showing a line or even just the function, it should have that information somewhere at least
18:06tickingI mean I hope it knows whiich funcitons it compiles
18:07brehauti generally it does. this appears to be an edge case
18:08tickingbrehaut, I don't belive you ;P
18:09brehautyou can belleve whatever you wish. it doesnt change facts
18:09emezesketicking: brehaut is correct. Also, the compiler's open source; I'm sure they'd accept a patch that fixes the problem in your case
18:11tickingemezeske, yeah but fixing a compiler of a language in turn for fixing a 200 lines evaluation program to check if the language is suitable for further projects seems to have a bad cost-return ratio ^^
18:20brehautticking: thats the trade off you make for considering a relatively young language
18:21tickingbrehaut 1.4 isn't young in my eyes, the erlang vm lisp is in 0.0.1 and has better error messages than clojure with a comunity of 5 I think…
18:22RaynesI wish more people would tell us how to fix Clojure.
18:23emezesketicking: So use the erlang vm lisp?
18:23socksandsandalsRaynes: lol
18:23brehautat v 1.4 the language is approximately 5 years old. erlang is ballpark 20 years old.
18:23Raynesbrehaut: He is talking about Joxa.
18:23socksandsandalsbrehaut: 25 this year
18:24RaynesI think.
18:24tickingemezeske, considered, not an option, universities can barely accept clojure because its ontop of java
18:24ibdknoxwat
18:24muhoobrain asplodes
18:24ibdknoxMost universities teach Java...
18:25tickingibdknox, ever tried to get a lisp project through in a traditionally oo/impertive environment?
18:25ibdknoxticking: lol
18:25tickingibdknox, yeah thats why clojure is barely accepted^^
18:26emezesketicking: Use java. It's mature.
18:26brehauterr, universities are one of the two strongholds of functional programming
18:26ibdknoxyeah
18:26ibdknoxI'm confused
18:26brehaut(along with the financial sector)
18:26tickingbrehaut, in _some_ departments yes ^^, the rest no chance
18:26socksandsandalsI don't understand Joxa
18:26ibdknoxticking: you must be talking about a specific university?
18:26socksandsandalsBEAM is barely acceptable as a VM for Erlang
18:27muhooi'm barely accepting this argument.
18:27tickingbrehaut, but 5 years is a lot of time to get error messages right ^^
18:28ibdknoxticking: I don't think anyone would argue Clojure's error messages should be better
18:28RaynesBut it isn't like they're useless.
18:28ibdknoxright
18:28RaynesIf you spend 10 minutes learning to read a stacktrace.
18:28RaynesIt does give you line numbers.
18:28RaynesEven hints around at what the issue is occasionally.
18:29socksandsandalsI'm pretty new to Clojure and I don't find them too difficult to understand
18:29ibdknoxmoreover, I'll take shitty error messages and a platform that can actually be used than say a language with awesome errors but that's built in its own little world
18:29emezesketicking: But what use is complaining? Fix it, help fix it, deal with it quietly, or go use something mature. Saying "the language is 5 years old, it should have better errors" doesn't change anything.
18:29RaynesI've written large applications in Clojure and lots of people have written much larger ones with lots of errors that we all managed to fix somehow, so something must be working.
18:30mkwhy doesn't clojure just map symbols to values? it seems to map symbols to vars, and the value of the var can change
18:30carkgfredericks: whatwhatwhat ?
18:31gfredericksmk: believe it or not that was intentional
18:31tickingemezeske, Raynes, I'd agree with that argument if it was some esoteric macro thing that one would have to deal with, or some werird syntax request, but I don't think there is anyting more fundamental to a languages usability than its behaviour when things go wrong
18:31kreig1blah blahb lah
18:31ibdknoxticking: what's your background?
18:31socksandsandalsticking: I assume you're at CMU?
18:31kreig1I have no problem debugging my 20k lines of clojure
18:31kreig1or before that 50k lines of CL
18:31RaynesThere are stacktraces.
18:32tickingibdknox, common/pico-lisp, io, self
18:32brehautticking is complaining because he hit an edge case
18:32tickingsocksandsandals, nope germany
18:32brehautthe stack trace is less helpful than normal
18:32carkkreig1: well to tbh CL's error system is top notch
18:32mkwhy was it intentional?
18:32kreig1file an issue in JIRA
18:32gfredericksmk: because it is quite useful; also note that not all symbols refer to vars
18:33kreig1cark: and restarts 8)
18:33carkkreig1: hehe yes good stuff
18:33tickingbrehaut, Raynes, reminds me of pauls old "Programming languages teach you not to want what they cannot
18:33tickingprovide."
18:33mkright, some refer to special forms, but that's fine, because you just check the special form map before checking the namespace map, no?
18:33kreig1cark: tho it really is an implementation thing, cmucl/sbcl is pretty good, franz is better in many caes, clisp was prolly the least useful
18:34brehautticking: re: 5 years is a long time to get error messages right: it depends on your priorities. maybe we could have better error messages if we gave up protocols or stm or persistant data structures…
18:34mkin what cases is it useful?
18:34kreig1cark: that said, no problem debugging in clisp
18:34gfredericksmk: also you have interop symbols and locals
18:34carkkreig1: i was using lispworks, it was good
18:34socksandsandalshow much is Franz these days?
18:34gfredericksmk: it's useful when you want to redefine something
18:34tickingbrehaut, exactly! protocols is nice but it is not fundamental, the basics should be right before you start with bells and whistles
18:35kreig1ticking: then fix them
18:35RaynesDo what everyone else does and write your own language. Obviously this one is all wrong.
18:35brehautticking: go use another language then
18:35kreig1ticking: really, we're a bit busy working to deal with trolls
18:35ibdknoxticking: you hit an edge case, I'm not sure I understand why you're complaining. Sounds like you found a bug
18:35kreig1except on sunday, which is troll day
18:35kreig1yah: I say file it in JIRA
18:35mkgfredericks: locals are created through let? how do they work now? I expect that all that is handled before ns is touched, no?
18:35ibdknoxticking: Stacktraces in Clojure are generally useful
18:36ibdknoxticking: things can always be better, but it's far form the dire situation you seem to be painting
18:36carkmk : locals are just like in any other language, like in java, only read-only
18:36carkor final really
18:37gfredericksmk: let/fn/loop; I'm not sure what you mean by "before ns in touched", nor what you want to know regarding how they work; they aren't vars
18:37tickingibdknox, I jsut stating as I experienced it, every error message I encountered was pretty useless
18:37ibdknoxticking: and this is your first use of Clojure?
18:37carkticking: they're good enough for me to find problems
18:38ibdknoxticking: have you ever read a Java stacktrace?
18:38tickingibdknox, pretty mutch wanted to use a lisp had to use something that works in "corporate environments" aka java
18:38tickingibdknox, yeah java was my first language
18:38cemerickcshell: Eclipse + Counterclockwise for everything Clojure
18:38clojurebotclojure > scheme
18:38cemerickas well as most javascript, HTML, and CSS
18:39ibdknoxticking: can you give examples of the errors you found useless?
18:39cemerickmacvim for miscellaneous non-project-related bits
18:39brehautibdknox: https://gist.github.com/3161113
18:39carkcemerick: what's the current status of counterclockwize, as compared to slime ?
18:39mkgfredericks: when the reader sees "(foo bar)", presumably it compiles (foo bar), where foo and bar are symbols. When the eval hits it, it does *ns*.get("foo"), and replaces the symbol with the value. What's wrong with that?
18:39brehautibdknox: his code is https://gist.github.com/3161132
18:39tickingibdknox, the compiler knows what went wrong, but won't tell you the function, I would be happy with that, what annoys me is that I know that that info is in there somewhere but the compiler doesn't print it
18:40cemerickcark: very, very approximately, they're largely equivalent.
18:40ibdknoxticking: sure, this is one example - you implied there were many?
18:40gfredericksmk: if they're locals that's not true
18:40cemerickThere are some features that each has that the other doesn't, but there's a ton of overlap.
18:40socksandsandalsseems pretty clear to me: you redefined "load"
18:40mkgfredericks: right - so there'd be a stack of maps that it checks before hitting *ns*
18:40brehautsocksandsandals: nah, thats the warning. theres a cast error immediately below that
18:41carkcemerick: thanks i'll look into it again
18:41socksandsandalsbrehaut: oic
18:41brehautsocksandsandals: i made the same mistake
18:41gfredericksmk: so otherwise that sounds essentially correct
18:41tickingibdknox, yeah but then I had the luck of only editing a few lines so I knew what was going on and could revert the changes
18:41Bronsais the (:require hook.image :as image) right?
18:42emezeskeI... I just...
18:42mkso why does *ns* return a var, which contains the value, instead of just returning the value?
18:42cemerickcark: Best to start with the betas track. Official releases are ~monthly maybe, betas go out ~weekly.
18:42emezeskeComplaining does not help. Helping helps.
18:42carkmk : what you're saying is conceptually correct, tho it's not how it actally works i suspect
18:42ibdknoxBronsa: no it isn't - that's what's blowing up
18:42carkcemerick: will do
18:42Bronsaibdknox: yeah, i meant, that's the problem
18:43mkcark: well, in clojure the namespace returns a var, and you have to get the value out of the var. I don't understand why this extra step is there
18:43carkmk : when you use *ns* in some call, what you get is the value bound to that var, not the var itself
18:43mk(I assume there's a good reason)
18:43gfredericksmk: do you agree that it's good to be able to change the value of a def'd name?
18:43carkso you're wrong there
18:44cark,(type *ns*)
18:44clojurebotclojure.lang.Namespace
18:44carksee that's not a var, that's a namespace
18:44mkcark: I'm not talking about *ns*, but using it to refer to "the current namespace"
18:44ibdknoxticking: there are a small subset of errors in NS decls that produce crappy traces like that. They are indeed frustrating and someone will assuredly fix it at some point - part of the problem is when that stuff comes into play. I'm sorry that his has marred your experience with the language.
18:44tickingibdknox, yeah that was it thanks, but where did the boolean come from?
18:44mkgfredericks: yeah but can't clojure do that through curNS.put("foo", newval)?
18:45ibdknoxticking: I can say that in the general case you shouldn't run into issues like this and for now, there's a pretty straightforward pattern to those sorts of errors so you learn in term how to deal with them.
18:45gfredericksmk: so let's make sure we're distinguishing what time things happen
18:45ibdknoxticking: I'm not sure to be honest
18:46tickingibdknox, oh boy ^^
18:46gfredericksyou're saying that at compile-time the compiler emits *ns*.get('foo'), and at runtime *ns*.get('foo') is called, right?
18:47carkmk: what are you trying to do, and what is your concrete problem ?
18:47mkok, good - no, I'm saying that at compile time the compiler emits symbol foo, and at runtime the symbol is evaluated
18:47mkcark: "understand clojure" :)
18:47kreig1hehe
18:47carkonly one way to do that, pick a project, work on it, make a mental model about it
18:48kreig1ticking: intersting, never seen the (seesaw core .. form of an argument to :use
18:48ibdknoxticking: In general I agree with you - fundamentals first, but honestly you have to keep in mind the fundamentals are still working themselves out at this point.
18:48gfrederickscark: surely asking questions isn't never appropriate
18:48ibdknoxticking: 5 years is not a long time to get something *completely* right :)
18:48ibdknoxsince you can't even know what right is, even 5 years in
18:49carkgfredericks: sure, but we've been going at it for a long while now, and i feel we hit a road-block
18:49carki might be wrong tho
18:49riley526Noob noir/ring question: how do you access the values in a ring-request map/object? (It is a map, right?) I tried (:request-method ring-request), but that returns null instead of :get.
18:49gfredericksoh I just jumped in
18:49riley526When I stringify the whole request, it looks just like a map. But (map? ring-request) returns false.
18:49ibdknoxriley526: ring request is a fn
18:50ibdknoxthat returns a map
18:50ibdknoxriley526: (:request-method (ring-request))
18:50gfredericksmk: off the top of my head, one reason that would be less efficient than the actual behavior is that resolving a symbol at runtime is almost certainly slower than derefing a var
18:50riley526ibdknox: WHAT... are you serious... I wasted way too much time last night on that. Haha.
18:51riley526ibdknox: Thank you very much. I guess the docs didn't make that clear enough to me.
18:51ibdknoxhm
18:51ibdknoxriley526: http://webnoir.org/autodoc/1.3.0/noir.request.html#var-ring-request - do you have suggestions?
18:51mkcark: some questions lead to others, and if things are stuck, which I don't think they are, a new person can often help
18:52carktrue
18:52tickingibdknox, yeah but after a 1.x I expect the fundamentals to work kinda reliable, belive me I know how it is to work with sub-par supported languages, take Io and Self for example, I was probably one in 20-50 who used them at all and one in 3 who actively worked on things, but at least the error messages worked ^^
18:53riley526ibdknox: Actually, no. It seems perfectly clear now. "Returns back the current ring request map" is really obvious.
18:53riley526ibdknox: I just had noob blinders on.
18:53kreig1ticking: I still think your being a bit dickish with this assertion that error messages don't work
18:54tickingibdknox, it's not really missing or broken stuff I get annoyed with, but every blog post you read about clojure errors, states they are lacking since 2010 ^^
18:54mkgfredericks: right, I think this is/was a problem in javascript, which did lookups this way. But I'm pretty sure that can be optimized without exposing the programmer to vars...
18:54kreig1ticking: because the experience o alot of other people don't back that up
18:54kreig1ticking: I find it's the errors in special forms that are the worse
18:54kreig1ticking: like the ns error you ran into
18:54carkmk : but you're not exposed to vars unless you do some pretty advanced namespace stuff
18:54ibdknoxticking: it's a matter of focus as someone said before. I personally would prefer so-so error messages and a language that I can use to do real work than great error messages and a language like (insert esoteric lang here).
18:55kreig1ticking: it's one reason also why you lose compiler and useful line info
18:55tickingkreig1, when I searched for clojure error messages on google (to fix this) I got a lot of blog posts form 2010, that state how errors bit them, and they looked exaxtly like they look now ^^
18:55carkmk : just (def stuff ... or (defn stuff, and there you go, code away, never thinking about vars
18:56ibdknoxticking: actually those complaints were largely about error messages before 1.3, which were pretty hard to deal with. Like I said, you unfortunately ran into a class of error that hasn't been dealt with well yet
18:56kreig1ticking: yah, so?
18:56carkjust like in javascript you don't really need to know objects are also maps unless you're doing pretty dvanced stuff
18:56gfredericksmk: another problem with your model is that it doesn't account for (:use) and (:require)
18:57cark(fior some value of advanced)
18:57ibdknoxticking: the reason why is largely that it falls in a weird space implementation-wise
18:57kreig1ticking: in your case, was the erorr in the ns form for you?
18:57tickingkreig1, so it seems to me that they are a known cause for hassle, yeah it was
18:57tickingibdknox, yeah I'll finish this small project and see how the other messages behave ^^
18:57mkticking: I'd drop it. I think you want people to acknowledge that error messages should be fixed, and sure, but they have different priorities. If your priorities put error messages that high, then implement it instead of wasting time convincing others that occasional bad error messages are driving people away from clojure.
18:58kreig1ticking: which line was it?
18:58kreig1ticking: i'm trying to reproduce a similiar error here
18:58tickingkreig1 2
18:58kreig1mk: we don't want him to drop it 8)
18:59mkkreig1: this much seems obvious ;)
18:59kreig1ticking: ah, the fact that you didn't make a refspec [foo :as bar]
18:59tickingyeah
18:59kreig1and since it all is in the form on "line 1" it tells you it's in the ns form, but not which part
19:00mkgfredericks: you'd just put a map under *ns* with those mappings that is checked when ns returns null
19:00tickingkreig1, yeah in general errors in the first line are artefacts though, so you don't immediately think of it really having the root in line 1
19:01mkerr, sorry, that wouldn't allow changes. I mean a map from symbol to the namespace that should be checked for that symbol.
19:01tickingkreig1, but srsly java.lang.Boolean cannot be cast to clojure.lang.Symbol, is just wat ^^
19:02kreig1uhm
19:02kreig1reading that stack trace tells me exactly where the problem is
19:02kreig1as someone familiar with core.clj
19:03kreig1literally, you can figure out what it is from there
19:03mkthe other effect that this would have is that you could define functions etc. containing symbols that aren't mapped in the ns - maybe that has something to do with why it's not done this way?
19:03kreig1tciking: but I totally agree
19:03kreig1ticking: and while that is the correct error and you can decipher it from reading a stack
19:03kreig1ticking: what shuld happen, is that the ns form should catch that badly formed :require line
19:04tickingkreig1, where is the line you see it in the st at hook.core$eval5$loading__4505__auto____6.invoke(core.clj:1) ?
19:04kreig1ticking: and give you a more explicit error, earlier, and not later when it tries to make an alias
19:05kreig1the core.clj:5352 line (that's incside (require
19:05kreig1ticking: open up core.clj and chck it out
19:05kreig1sorry, I'll slow down and type better...
19:05tickingkreig1 currently skimming through it ^^
19:06kreig1ticking: it's calling load-libs on a list '(hook.image :as image)
19:07tickingkreig1, ah right now I see the corresponding require call in the pst
19:07kreig1ticking: so, what SHOULD happen, I think, ona sunday afternoon after a beer, mind you -- the require form should throw an error when it gets a keyword as a library to load
19:08mkwhy is it a bad idea to allow (fn [] (foo)), where foo has not been defined?
19:10tickingkreig1, possible, but this just catches a very specific border case (forgotten []), doesn't it?
19:10siscianewbie question: What i need to implement to get my type unique in a set ? I have implemented Object.equals and Object.hashCode but if I try to make a set with equals structure the repl simply esc with "Evaluation aborted"...
19:11kreig1ticking: yah, but that's the correct place to catch it iMO
19:12mksiscia: is equals implemented correctly?
19:12sisciamk, i am not sure...
19:13kreig1ticking: the fact that it's a Boolean cannot be cast to Symbol that blows up is indeed esoteric
19:13siscia(equals [this other] (= (:name this) (:name other)))
19:13kreig1ticking: but the stacktrace does tell you where it happend 8^)
19:13mksiscia: how is hashcode implemented?
19:13emezeskesiscia: There are some very specific rules you need to follow for Java's .equals: http://www.jeggu.com/2009/11/5-rules-to-override-equal-method-in.html
19:14siscia(.hashCode (:name this))
19:14kreig1ticking: the call to (alias as lib) in load-lib, I bet it's passing a null or false as the lib argument
19:14tickingkreig1, yeah it kinda does^^ gruesome long sts is probably something clojure inherited form java, I wonder why the pst form isnt the default ^^
19:14emezeskesiscia: I'm not certain if a buggy equals could cause the exception you saw
19:14kreig1ticking: pst form? I'm lost
19:14ticking(pst)
19:15emezeskesiscia: Is (:name this) an integer?
19:15tickingkreig1, the form it prints when you use the repls? pst funciton
19:15sisciano it's a key
19:15sisciaemezeske, no it is a key
19:15emezeskesiscia: Isn't .hashCode supposed to return an integer?
19:16sisciaemezeske, is not a string...
19:16emezeskesiscia: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Object.html#hashCode()
19:16kreig1ticking: well pst would have not told you where the bug was actually
19:16emezeskesiscia: I think hashCode has to return an int.
19:16kreig1ticking: it would have said "somewhere in the ns form"
19:16mksiscia: ^ the hash with 89735 to not conflict strings
19:16kreig1throwing info OUT o the stacktrace IMO, is shitty
19:16tickingkreig1, yeah that's something I'm completely happy with ^^
19:16sisciayeah you are right
19:17kreig1ticking: no way
19:17sisciaemezeske, but it does...
19:17tickingkreig1, well yeah but only if you don't have a non-default way to show more ^^
19:17emezeskesiscia: Oh, one other rule: .hashCode needs to depend on all of the fields that might affect .equals
19:18kreig1ticking: I see that as your UIs job, not the runtime
19:18sisciaemezeske, it does
19:18emezeskesiscia: Hah, I got nothing then :)
19:18kreig1ticking: cause if I get a stacktrace someplace in my app, I want to see the whole fucking thing in my log
19:18tickingkreig1, point accepted^^
19:18kreig1cause, I can't reproduce it easily
19:18kreig1ticking: but let's take this someplace productive
19:19kreig1ticking: it seems to me that the ns form and the request/use forms could stand some better error chcking and error messages that would be helpful
19:19sisciaemezeske, https://gist.github.com/3161358
19:19kreig1ticking: cause everyone uses namespaces, and I'm sure everyone makes this same mistake
19:19tickingkreig1, possible ^^
19:20emezeskesiscia: Looks reasonable to me. I don't do a whole lot with deftype, though, so I won't be much help :(
19:21sisciaemezeske, thanks anyway...
19:21kreig1ticking: you using 1.3.0?
19:21tickingkreig1 1.4.0
19:22kreig1ticking: let me pull that down
19:22sisciamy point is that i need something that given an identical field would be the same in a set...
19:22kreig1ticking: my CA letter should have been received by now, let's make a patch for this
19:23kreig1ticking: hah, 1.4.0 ns is pretty much the same as 1.3.0
19:24mksiscia: hashsets use hashcode and equals, treesets use comparable
19:24mksiscia: usually if there are fields not factored into equals, they... shouldn't be there
19:26sisciamk, sorry i wasn't clear... I was talking about hashset
19:26kreig1ticking: hah, looks like you could invoke any clojure.core fn you want in an (ns .. form
19:26kreig1tciking: look at core.clj:5117
19:27tickingkreig1, in condp?
19:27sisciamk, yeah I see what you mean... but i need both field and only one must be unique
19:28tickingkreig1, oh sorry followed a bad google link and got a bad code revision ^^
19:28kreig1ticking: hmm, no this is in the (defmacro ns form in clojure core.clj 8)
19:29kreig1basically it takes the keyword (:require, looks it up in clojure.core and invokes it on that args
19:30kreig1user> (ns foo (:print "HARuser> (ns foo (:print "HARHAR"))
19:30kreig1HARHARnil
19:30kreig1,(ns foo (:load "foo.clj"))
19:30clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate foo.clj__init.class or foo.clj.clj on classpath: >
19:30tickingkreig1, oh right, 0o
19:30kreig1haha
19:31kreig1hmm, go try that on some of the "try clojure" websites
19:31kreig1wonder if you can bypass their attempts at restricting your evaluation namespace
19:31tickinglol
19:31tickingwonder what clojurebot thinks of this ^^
19:31kreig1see the runtie exception?
19:33tickinglol
19:33kreig1ok, so we might wanna put that check in the macro expander 8)
19:34kreig1err, I should get a proper checkout of clojure for this, gimme a minute
19:34tickingthis is what tryclj says about itClojure> (ns foo (:load "foo.clj"))
19:34tickingjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Compiler is bad!
19:34mksiscia: try creating a new Node on its own
19:34kreig1oh sweet
19:34kreig1good on them
19:35sisciamk, I was trying right now and it weird... Because it give me "Evaluation Aborted"...
19:35kreig1ticking: in the meantime, you could write a version of (require that makes sure that it's args are a symbol, or a vector whose first value is a symbol
19:36tickingkreig1, I'll see what I can do ^^
19:36kreig1and (throw (new Exception ...
19:37kreig1nice part about largely self-hosting lisps 8)
19:38siscia,(deftype Node [name table] Object (equals [this other] (= (:name this) (:name other))) (hashCode [this] (.hashCode (:name this)))
19:38clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
19:38siscia,(deftype Node [name table] Object (equals [this other] (= (:name this) (:name other))) (hashCode [this] (.hashCode (:name this))))
19:38clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
19:39sisciaSorry about that...
19:41tickingkreig1, looks like all the work is done by load-libs, which seems to also handle :use
19:42gfredericksmk: aside from the performance stuff mentioned earlier, I don't know any reason that symbol compilation (minus dynamic bindings) couldn't be handled the way you describe. I've thought about this before; if you find out anything, I'd be curious to hear it
19:42kreig1ticking: yup
19:43kreig1ticking: however, require/use are the user facing interfaces for that
19:43kreig1ticking: so I'm inclined to put any error checking in there
19:43tickingkreig1, sounds reasonable
19:43kreig1ticking: because if you look at load-lib, it's API is kinda complex
19:44kreig1and, having it throw an error, it doesn't know which user facing func was called
19:44tickingkreig1 yeah
19:44kreig1ticking: It could raise an error, ":as is not a valid library name" or something like that
19:44kreig1ticking: but won't help much
19:44kreig1ticking: only slightly less opaque than Bool can't be shoved into Symbol hole
19:45kreig1,(ns foo (:print "I AM A ROBOT!"))
19:45clojurebotI AM A ROBOT!
19:46tickingkreig1, thats a really weird implementation side effect
19:47kreig1yah 8)
19:47mkgfredericks: perhaps something to do with importing functions from other namespaces?
19:47kreig1hahaha
19:50gfredericksmk: no, I think that would all work using the imports map you mentioned
19:51amalloygfredericks, mk: if you allow symbols which aren't defined, the compiler can't give you error messages early
19:51amalloyyou're playing around at the repl and you (defn foo [] (princ 1))
19:51gfredericksamalloy: presumably not ever, since eval is allowed at runtime
19:51amalloyit can't complain that you forgot what lisp you're in, because maybe you're planning to define princ later
19:52kreig1ticking: I gotta run an errand, I am reachable at craig@red-bean.com and will be back later.
19:52mkgfredericks: if I have a local foo equal to 1, and the function depends on an external foo equal to 2, then importing and evaling the function will hit the local 1 before it hits the 2
19:52kreig1ticking: let's put some patches together and contribute them
19:52tickingsure, I think I'll hit the hay for a few hours too, its 2am here in germany ^^
19:52gfredericksmk: importing shouldn't have anything to do with evaling
19:53gfredericksamalloy: do you if there's anything semantically wrong with the varless model of symbol compilation we've been talking about?
19:53tickingkreig1, I'll see where I can help as I'm pretty new to clojure ^^
19:53amalloyi dunno, i haven't been listening
19:53mkgfredericks: you pass an imported function into one of your own functions in namespace one. The imported function's vars should resolve to two, but instead they now resolve to one. No?
19:53tickingkreig1, but I'm sure it'll be fun see you later and good luck :D
19:54gfredericksmk: not in my head
19:54kreig1ticking: judging by your background, I think tightening up use/require is well without your grasp
19:54kreig1ticking: within 8)
19:54tickinghrhr
19:55mkgfredericks: in js functions keep references to the scope under which they were defined... so yeah, I guess the original namespace can just be inside the function's closure?
19:55gfredericksyep
19:56kreig1ticking: the hard part, is that you have to use only the stuff already define in core.clj 8)
19:56tickingkreig1, ah I see, sounds interesting
19:57mkamalloy: the idea is to remove vars (so now namespaces map symbols to values, rather than to vars containing values), and resolve symbols at runtime
19:57tickingkreig1, so the smaller the line number of the functions head the harder it is to write
19:57kreig1in this case, perhaps *)
19:58kreig1althoughy ou basically have most of the list opertions and such
19:58tickingkreig1, ah ok ^^
20:02mkgfredericks: if it's really just performance, than perhaps the best way to think of vars is simply as a key-value pair... but it's strange that this is exposed at all, when it could be hidden
20:03mkjust say "clojure looks up symbols in the namespace and other places, though under the hood things are more complicated"
20:07haspakerGood evening
20:09Bronsais it evening in the US?
20:09haspakerI have absolutely no idea
20:09kreig1early evening
20:09haspakerHere in Sweden it's in the middle of the night
20:10haspakerWhat kind of features does Sublime Text need in order to be useful for clojure development?
20:10haspakerI have already fixed the indentation and rainbow parentheses
20:13nicholasflooking for ways to integrate with github - for oauth. Id prefer to use nginx than Apache, and https://github.com/mattrepl/clj-oauth/ seems to mandate apache
20:13nicholasfhas anyone done this?
20:14brehautnicholasf: seen https://github.com/raynes/tentacles/ ?
20:14nicholasfbrehaut: looking now
20:15nicholasfbrehaut: this looks really interesting
22:55Raynesnicholasf: It wont help you get an oauth access token though. You'll have to use one of the oauth libs for that, or just basic auth.
22:57nicholasfRaynes: thanks mate
23:46haspakerDo anyone here know a nice color scheme for clojure on a dark background?
23:47wmealingyou'll usually need to discuss which editor
23:49clj_newb_28489sup wizards of the 1023rd level of clojure
23:49clj_newb_28489so I'm using clojurescript, trying to setup a clojurescript repl
23:49clj_newb_28489and I have the exact same piece of code; checked into git
23:49clj_newb_28489and it works on my dekstop imac, but not my laptop macbook pro
23:49clj_newb_28489these two machiens have the _exact_ same maven repos, the exact same lein config setups
23:49clj_newb_28489running the exact same code
23:49clj_newb_28489they even have the exact same version of chrome
23:50clj_newb_28489one of them -- I get a clojurescript repl just fine
23:50wmealingerrors in the js console ?
23:50clj_newb_28489the other .... it gives me errors about: Uncaught TypeError: Cannot call method 'call' of undefined repl:1221 Uncaught TypeError: Cannot read property 'client' of undefined
23:50clj_newb_28489(I'm using chrome's built in debugging tools)
23:50wmealingif you restart chrome, does it work ?
23:50wmealing(chrome does magical live updates)
23:50clj_newb_28489then, when I click on those, it brings me into incomprehensible levels of clojurescript code
23:50clj_newb_28489hmm
23:51wmealingi guess he's on the macbook pro
23:51clj_newb_2834020clever way to get me to kick myself out of #clojure :-)
23:51clj_newb_2834020i will now run web chat in safari, and do my code testing in chrome
23:51wmealingtotally, right ?
23:51wmealingsorry dude
23:52clj_newb_2834020Uncaught TypeError: Cannot call method 'call' of undefined repl:1221 Uncaught TypeError: Cannot read property 'client' of undefined
23:52clj_newb_2834020same error
23:52clj_newb_2834020when I click on the line, it gets me this line:
23:52clj_newb_2834020goog.net.xpc.CrossPageChannel.prototype.disposeInternal=function(){goog.net.xpc.CrossPageChannel.superClass_.disposeInternal.call(this);this.close();this.iframeElement_=this.peerWindowObject_=null;delete goog.net.xpc.channels_[this.name];this.deferredDeliveries_.length=0};goog.net.xpc.CrossPageChannel.disposeAll_=function(){for(var a in goog.net.xpc.channels_){var b=goog.net.xpc.channels_[a];b&&b.dispose()}};clojure.browser
23:52clj_newb_2834020"Uncaught TypeError: can not call method 'call' of undefined"
23:53wmealinghmm
23:53clj_newb_2834020clojure Object clojure.browser Object clojure.browser.repl Object clojure.browser.repl.client undefined
23:53clj_newb_2834020hmm, is clojure.browser.repl.client supposed to be undefined or an object?
23:54wmealingi dont know enough about clojurescript
23:54wmealingit might be a security setting in your browser
23:54wmealing(or addon)
23:54wmealingCrossPageChannel is something to do with javascript executing across different domains, iirc
23:56clj_newb_2834020i have no extensions installed
23:56clj_newb_2834020and basically everything is allowed
23:58wmealingonly breaks in chrome ? other browsers are fine ?
23:58clj_newb_2834020doesn't work in safari either
23:59wmealingjvm versoin ?
23:59clj_newb_2834020installing firefox now
23:59wmealingno, not jvm
23:59wmealingidiot
23:59wmealingshould be running the same js engine version
23:59clj_newb_2834020firefox fails too