2012-07-22
| 00:00 | rlb | can't help you there either -- I haven't looked at how clojure compiles to the JVM much at all. |
| 00:00 | mk | why doesn't (clojure.string/split ...) auto-require clojure.string, as java.util.Map would "auto-import" Map? |
| 00:00 | rlb | Might want to look here: http://clojure.org/compilation |
| 00:00 | mk | rlb: thanks for the link |
| 00:07 | amalloy | mk: a function is a class, inside the package its namespace represents |
| 00:07 | amalloy | &(class inc) |
| 00:07 | lazybot | ⇒ clojure.core$inc |
| 00:08 | mk | ah, I see |
| 00:09 | amalloy | well, 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:09 | amalloy | there a single instance of the 'adder class is created, and two instances of the 'inner class are created |
| 00:09 | mk | is the inner bound to any namespace? |
| 00:10 | amalloy | no, it's anonymous |
| 00:10 | amalloy | it happens to be within one because it has to live in a package to exist |
| 00:10 | amalloy | &(let [adder (fn [x] (fn inner [y] (+ x y)))] (class (adder 1))) |
| 00:10 | lazybot | ⇒ sandbox81632$eval84433$adder__84434$inner__84435 |
| 00:11 | mk | that makes sense |
| 00:12 | mk | if I create many functions in clojure at runtime, will Java code see them? |
| 00:18 | amalloy | that question is too ill-defined to answer |
| 00:22 | mk | I 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:23 | amalloy | it doesn't modify one of its classes |
| 00:23 | amalloy | classes are not mutable, in java or clojure |
| 00:23 | mk | I'm basically wondering about how code knows about other code on the jvm |
| 00:24 | mk | can a class not be replaced by another class of the same name using clojure? |
| 00:36 | ro_st | so it looks like clojurescript doesn't support vars of fns at all? |
| 00:38 | ro_st | as 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:49 | AtKaaZ | this question was bothering me in my sleep: is the only way to add/remove/modify clojure code via repl ? |
| 03:51 | AtKaaZ | if 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:57 | ivan | AtKaaZ: no, anything can load new code (via require I guess) |
| 04:00 | AtKaaZ | but 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:01 | AtKaaZ | come to think of it, that's quite like what 4clojure.com is doing |
| 04:02 | AtKaaZ | but I don't know how they're doing it, I'm hoping not by pasting that to the repl somehow |
| 04:03 | AtKaaZ | ivan, with require it seems the code must already exist somehow "The require function loads Clojure libraries." |
| 04:04 | ivan | (eval (read-string "(+ 1 1)")) |
| 04:05 | ivan | REPL = read eval print loop; you'll find the (eval call in repl.clj :) |
| 04:06 | AtKaaZ | wow that's quite epic I was able to define a function with that and use it later |
| 04:06 | ivan | er, that other file |
| 04:07 | AtKaaZ | so that's how to write dynamic code? |
| 04:08 | ivan | yeah, but there is generally no need for eval |
| 04:08 | AtKaaZ | just read-string then? |
| 04:09 | AtKaaZ | this is quite awesome |
| 04:09 | ivan | well, read-string will load Clojure data structures but not call anything (excl. the "=(" evil) |
| 04:10 | AtKaaZ | how can i see the source code for read-string, I did (source read-string) |
| 04:11 | ivan | the (clojure.lang.RT/readString s) means it's implemented in RT.java |
| 04:12 | AtKaaZ | if it were in a .clj I would be able to see the clojure code? |
| 04:12 | AtKaaZ | via the source |
| 04:12 | ivan | yes |
| 04:12 | AtKaaZ | cool than, thanks for this info |
| 04:13 | ivan | you were looking at the Clojure source though; defn read-string is in core.clj |
| 04:14 | aib | is there a way to get the definition of a macro? |
| 04:14 | AtKaaZ | oh that [s] meant this is the source code [s] (clojure.lang.RT/readString s) |
| 04:14 | yy | \o/ |
| 04:15 | AtKaaZ | The source function, in the clojure.repl library, uses this metadata to retrieve the source code for a given function or macro. |
| 04:16 | AtKaaZ | ,(source reverse) |
| 04:16 | clojurebot | Source not found |
| 04:17 | ivan | AtKaaZ: the [s] is just the argument list for the function |
| 04:17 | aib | AtKaaZ: thanks |
| 04:18 | AtKaaZ | yeah I was about to say that, as I just noticed for reverse |
| 04:18 | plainflavored | how difficult do you think it would be to implement clojure in python? |
| 04:18 | AtKaaZ | [coll] (reduce1 conj () coll) |
| 04:19 | AtKaaZ | https://github.com/eigenhombre/PyClojure/ |
| 04:19 | plainflavored | rad! thank you |
| 04:19 | AtKaaZ | actually, they say: clojure-py project is further along |
| 04:20 | AtKaaZ | this: https://github.com/halgari/clojure-py |
| 04:24 | aib | ,(#(+ %1 %2) 21 21) |
| 04:24 | clojurebot | 42 |
| 04:29 | mikem | where can I find clojure.contrib.io/read-lines today? |
| 04:31 | mikem | or it's been deprecated outright? |
| 04:46 | AtKaaZ | mikem: http://freegeek.in/blog/2011/06/10-clojure-one-liners/ scroll down to 4. Read a File |
| 04:48 | mikem | AtKaaZ: yep, i saw that. thanks :-) |
| 04:51 | mikem | but 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:52 | Raynes | Because that is something completely entirely utterly different from what the other thing does. |
| 04:52 | Raynes | Are you trying to read the string into a map, mikem? |
| 04:52 | Raynes | &(read-string "{:foo 1 :bar 2}") |
| 04:52 | mikem | Raynes: yes |
| 04:52 | lazybot | ⇒ {:foo 1, :bar 2} |
| 04:52 | Raynes | read-string is what you want. |
| 04:53 | mikem | oops, that's a typo. I am using read-string, not read-line |
| 04:53 | Raynes | Note 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:53 | mikem | the issue is with read-string returning a blank symbol |
| 04:53 | Raynes | What is a 'blank symbol'? |
| 04:54 | mikem | at 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:55 | mikem | if i pass a string literal to read-string it works, but on an instance of java.lang.String it doesn't |
| 04:55 | Raynes | A string literal is a java.lang.String. |
| 04:56 | hiredman | what do you think a string literal is? |
| 04:56 | mikem | heh you're right |
| 04:56 | Raynes | And that doesn't make any sense. What does the map look like? |
| 04:56 | Raynes | The actual map you're trying to read? |
| 04:56 | mikem | "{:text \"hello\", :id 10}" |
| 04:57 | Raynes | Do this for me: (prn (read-string (with-open [..] (first (line-seq ..)))) |
| 05:00 | mikem | what's the preferred pastebin for Clojure code? |
| 05:00 | Raynes | https://www.refheap.com is generally preferred these days, I think. |
| 05:00 | Raynes | I totally didn't write it. |
| 05:00 | AtKaaZ | lol |
| 05:00 | mikem | haha |
| 05:01 | mikem | Raynes: https://www.refheap.com/paste/3729 |
| 05:02 | Raynes | mikem: Sec. |
| 05:04 | Raynes | mikem: Yeah, I'm totally lost. This shouldn't be happening. |
| 05:04 | Raynes | mikem: Perhaps restart the repl? Maybe read-string got redefined somehow or something. |
| 05:04 | Raynes | Beyond that, I can't see any issues. |
| 05:05 | mikem | were there any known issues recently with read-string? |
| 05:05 | Raynes | I can't reproduce what you're seeing. |
| 05:06 | Raynes | I don't know of any version of Clojure that had a read-string that was broken like this. |
| 05:06 | Raynes | antares_: Hello there, good sir. |
| 05:06 | antares_ | hey Raynes |
| 05:06 | Raynes | antares_: Sorry I haven't had a chance to do what you asked in monger and friends. |
| 05:06 | Raynes | Might start poking around tomorrow. |
| 05:06 | antares_ | that's ok |
| 05:06 | antares_ | thanks! |
| 05:07 | Raynes | Will ping you with any findings. |
| 05:07 | mikem | Raynes: so when you try to read-string something that comes out of line-seq, everything works? |
| 05:07 | Raynes | mikem: Yup. |
| 05:07 | mikem | which version of Clojure are you using? |
| 05:07 | Raynes | 1.4 |
| 05:07 | Raynes | But this should work in any version. |
| 05:07 | Raynes | Did you try restarting the repl? |
| 05:09 | mikem | Raynes: yeah, still broken. I'm also using Clojure 1.4.0. Besides, this doesn't really strike me as something that would break |
| 05:10 | AtKaaZ | that works for me too |
| 05:10 | AtKaaZ | on windows |
| 05:11 | AtKaaZ | with eclipse and ccw |
| 05:13 | AtKaaZ | how can I know what version of clojure I'm using from repl ? |
| 05:15 | AtKaaZ | ,(clojure-version) |
| 05:15 | clojurebot | "1.4.0-master-SNAPSHOT" |
| 05:15 | AtKaaZ | I'm on 1.3.0 |
| 05:17 | mikem | ok, 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:19 | AtKaaZ | how could you guard against that in the future? |
| 05:19 | AtKaaZ | ,*clojure-version* |
| 05:19 | clojurebot | {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"} |
| 05:27 | aib | "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:28 | mikem | aib: yeah, probably. the [] reader literals for vectors save you the trouble |
| 05:46 | AtKaaZ | mikem, 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:52 | AtKaaZ | screenie: http://s18.postimage.org/tlyj9l3qv/null_char.png |
| 05:52 | mikem | AtKaaZ: i'm not sure which character it was. In vim it appeared as ^@ and in hexedit it was 00. |
| 05:52 | AtKaaZ | yeah that's the one I used too |
| 05:54 | AtKaaZ | what I was trying to say is that it somehow didn't visually show on your console and thus made it harder to realize |
| 09:40 | jsnikeris | technomancy: Are you there? |
| 09:49 | augustl | technomancy: ref environment variables for credentials to repos - doesn't it make sense to support an unencrypted credentials.clj too in that case? |
| 09:50 | augustl | if 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:07 | cshell | has anyone had any problems using the environ.core library in 1.4? |
| 11:58 | cshell | did something change with lein 2 with regards to the lein deps command? |
| 12:03 | jsnikeris | cshell: I think it uses Pomegranate now. |
| 12:18 | jst25 | i'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:18 | jst25 | I'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:21 | mk | jst25: a few google results for "No protocol method * defined for type object: [object Object]" |
| 12:22 | mk | jst25: do any of those seem on track? |
| 12:23 | mk | http://clojure.org/books is this page blank for just me? |
| 12:24 | jsnikeris | mk: it's not blank for me |
| 12:25 | mk | there are books visible? |
| 12:25 | jst25 | mk: 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:25 | jst25 | mk: and i'm also not seeing any books |
| 12:27 | mk | jst25: yeah, I've learned that it's a really useful trick for errors with variable text in the middle |
| 12:27 | mk | I wonder why the books aren't showing... |
| 12:27 | mk | oh, adblock |
| 12:33 | ambrosebs | I just pushed another alpha of Typed Clojure, should be fun to toy around with if you're so inclined |
| 12:36 | mk | is there an overview somewhere of what the various clojure books are like? |
| 12:38 | jst25 | mk: I think I've seen people discussing it here in irc before |
| 12:38 | jst25 | searching the logs might be useful |
| 12:40 | jst25 | i can't seem to find the specific discussion i was thinking of right now though sorry |
| 12:40 | mk | yeah, though I was hoping for something more... directly comparing them |
| 12:48 | harja | Does someone have experience with quil? I have this http://pastebin.com/gpQ9hYTN |
| 12:48 | harja | What am I doing wrong? |
| 12:55 | mk | harja: do you want doseq? |
| 12:55 | mk | http://clojuredocs.org/clojure_core/clojure.core/doseq |
| 12:58 | harja | mk: Ah, fantastic :) |
| 12:58 | harja | I tried do inside for but it did not do the same thing |
| 12:58 | harja | I'm very new to clojure so this is all guesswork for me atm |
| 12:59 | mk | the cheatsheet is helpful http://clojure.org/cheatsheet |
| 12:59 | mk | at the bottom of "for" there's a see also |
| 12:59 | rlb | harja: "for" is lazy, so if you don't use the result, nothing may happen. |
| 13:00 | harja | rlb: okay, that makes sense |
| 13:00 | rlb | and even if you do use the result, itm may not happen when you want it to. |
| 13:00 | harja | so basically when I want to run any seqs, lists or anything, I use do |
| 13:00 | gfredericks | no doseq |
| 13:00 | harja | yes, do* :) |
| 13:00 | harja | so for seqs it's doseq |
| 13:00 | gfredericks | but yeah, 'do' normally applies to side effects |
| 13:00 | harja | if it's just plain exprs, its o |
| 13:01 | harja | do |
| 13:01 | rlb | harja: there's also doall. |
| 13:01 | rlb | (if you want to force the evaluation and keep the result) |
| 13:02 | gfredericks | and dorun |
| 13:02 | gfredericks | for forcing without keeping |
| 13:02 | harja | dorun, doseq, doall seems to be my options in the cheat sheet |
| 13:03 | harja | are vectors and lists freely exchangeable as parameter lists and such? |
| 13:03 | harja | I've heard that vectors are to be used in clojure instead of pure lists |
| 13:04 | gfredericks | &(fn (a b) (+ a b)) |
| 13:04 | lazybot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol |
| 13:04 | rlb | harja: depends on what you mean -- syntax-wise clojure requires vector for declarations, i.e. (fn [] ...) |
| 13:04 | rlb | i.e. they're not generally interchangable wrt syntax. |
| 13:04 | rlb | fn/let/doseq/etc. |
| 13:04 | harja | rlb: 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:05 | gfredericks | yeah that's the seq interface |
| 13:05 | harja | yes, that's what I was looking for |
| 13:05 | gfredericks | normally anything seqable can go there |
| 13:05 | gfredericks | ,(apply str "hooha") |
| 13:05 | clojurebot | "hooha" |
| 13:06 | rlb | (including maps, sets, etc.) |
| 13:06 | harja | yeah, that's kind of obvious given that info :) |
| 13:06 | harja | well, back to learning. so far this has been quite a fun stuff |
| 13:06 | harja | thanks for your answers |
| 13:06 | mk | I guess doseq is like -> ? |
| 13:07 | gfredericks | no |
| 13:07 | mk | in that it pushes the args into a single form |
| 13:08 | gfredericks | doseq doesn't do syntactic manipulation like that. it iterates through your seq and evals expressions on each item |
| 13:09 | mk | right, no threading, but it does push arguments into a form |
| 13:09 | gfredericks | ,(macroexpand '(doseq [x [1 2 3]] (print x) (print x "foo"))) |
| 13:09 | clojurebot | (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:10 | gfredericks | mk: I'm not really sure what you mean by that |
| 13:11 | mk | perhaps it's not like that... what I mean is: |
| 13:11 | mk | ,(doseq [x 1] (prn x)) |
| 13:11 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 13:11 | gfredericks | ,(macroexpand-1 '(doseq [x [1 2 3]] (print x) (print x "foo"))) |
| 13:11 | clojurebot | (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:12 | mk | ,(doseq [x [1]] (prn x)) |
| 13:12 | clojurebot | 1 |
| 13:12 | mk | ,(-> 1 (prn)) |
| 13:12 | clojurebot | 1 |
| 13:13 | gfredericks | mk: -> does that at the syntactic level; doseq doesn't, or else it could only work with seq literals |
| 13:14 | gfredericks | so I think anything you're thinking of applies equally well to let |
| 13:15 | mk | well what I'm thinking is that the two are similar because they (ultimately) push arguments into functions |
| 13:16 | mk | -> keeps on pushing, while doseq pushes different arguments |
| 13:16 | mk | and of course doseq requires a binding |
| 13:18 | mk | the form in the pastebin was (for [[x y] [[10 10] [20 20] [30 30] [40 40]]] (rect x y 100 100)) |
| 13:19 | mk | I was wondering if there was something like (~> [[10 10][20 20][30 30][40 40]] (rect 100 100) ) |
| 13:20 | mk | since this would get rid of the binding, which seems a bit messy |
| 13:20 | gfredericks | will in that particular case x and y are always the same, so no reason to have two names |
| 13:21 | gfredericks | (for [z [10 20 30 40]] (rect z z 100 100)) |
| 13:21 | mk | right, I was just pasting the example, but assume they differ, but must be pushed into that standard first-parameter slot |
| 13:23 | mk | (for> [10 20 30 40] (square 0 5)) |
| 13:24 | mk | I'm pretty sure -> and ->> are the only ones with that non-bound format, though... |
| 13:27 | gfredericks | that's because they work at the syntactic level; for/doseq/etc don't mess with your form at all |
| 13:27 | gfredericks | so I think these kinds of comparisons are likely only going to confuse anybody |
| 13:33 | mk | don't know about that. They're different, but ultimately they're both for pushing parameters into functions (rather than, say, generating a seq) |
| 13:33 | gfredericks | does let push parameters into functions? |
| 13:35 | mk | I'm not sure, but I'm thinking of it more as something like a definition, or shorthand, or a rule of replacement |
| 13:37 | gfredericks | they're not remotely interchangeable; you can do things with -> that wouldn't compile with doseq |
| 13:38 | gfredericks | ,(-> 7 (/ 0) (try (catch Exception e :haha)) (assert)) |
| 13:38 | clojurebot | gfredericks: It's greek to me. |
| 13:38 | gfredericks | wat |
| 13:38 | gfredericks | &(-> 7 (/ 0) (try (catch Exception e :haha)) (assert)) |
| 13:38 | lazybot | java.lang.SecurityException: You tripped the alarm! catch is bad! |
| 13:38 | eggsby | huh, catch is bad? |
| 13:38 | clojurebot | Pardon? |
| 13:38 | gfredericks | in any case, there's nothing comparable to that with doseq |
| 13:39 | mk | eggsby: the bot is scared of it for security reasons |
| 13:39 | harja | what 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:40 | gfredericks | &(partition 2 1 (range 10)) |
| 13:40 | lazybot | ⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9)) |
| 13:40 | gfredericks | harja: ^ |
| 13:40 | mk | gfredericks: 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:40 | harja | gfredericks: yeah, just like that |
| 13:40 | harja | What if I want to wrap that around |
| 13:40 | harja | so the last element would be (9 0) |
| 13:41 | gfredericks | there'd be a few different ways to hack that together |
| 13:41 | gfredericks | easiest is ##(let [coll (range 10)] (concat (partition 2 1 coll) [(last coll) (first coll)])) |
| 13:41 | lazybot | ⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) 9 0) |
| 13:41 | mk | create a loopy range |
| 13:41 | gfredericks | no not quite |
| 13:42 | gfredericks | mk: that's cycle |
| 13:42 | gfredericks | but that would work too... |
| 13:42 | gfredericks | &(let [coll (range 10)] (take (count coll) (partition 2 1 (cycle coll)))) |
| 13:42 | lazybot | ⇒ ((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) (9 0)) |
| 13:42 | harja | that seems good. I came up with that first one |
| 13:43 | gfredericks | probably the only way to do it with one pass through the seq would be something complex with lazyseq |
| 13:43 | gfredericks | not worth it unless your coll is hugegantic |
| 13:43 | harja | yeah, I have a collection of 30 to 50 elements for now |
| 13:44 | harja | so performance is not really an issue here :) |
| 13:44 | gfredericks | that should be enough for anybody |
| 13:46 | mk | is there one for spinning a seq around? (1 2 3) -> (2 3 1) |
| 13:46 | mk | or is that impossible due to infinity? |
| 13:48 | gfredericks | it's okay for a seq function to hang on infinite seqs |
| 13:48 | gfredericks | &(last (range)) |
| 13:48 | lazybot | Execution Timed Out! |
| 13:48 | gfredericks | lazybot: botsnack |
| 13:48 | lazybot | gfredericks: Thanks! Om nom nom!! |
| 13:48 | gfredericks | I wonder how far he got |
| 13:50 | mk | not far enough |
| 13:53 | harja | how to include for example the combinatorics package in clojure.math.combinatorics to my leiningen 2.0 project? |
| 13:53 | harja | how do I know what the version number should be |
| 13:53 | harja | in the project.clj file |
| 13:54 | jasonjckn | harja: try [org.clojure/math.combinatorics "0.0.4-SNAPSHOT"] |
| 13:54 | jasonjckn | you may need to use "0.0.3" |
| 13:54 | harja | jasonjckn: Thanks, where did the version number come from? |
| 13:55 | jasonjckn | 0.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:55 | jasonjckn | 0.0.3 from maven repository http://mvnrepository.com/artifact/org.clojure/math.combinatorics |
| 13:55 | harja | okay |
| 13:57 | mk | (??? [a (mod a 3] (range 3)) -> ((0 1)(1 2)(2 0)) ? |
| 13:57 | mk | plus a paren. Is there anything that does that? |
| 14:10 | TimMc | mk: Not sure precisely what you want, but you might look at partition/partition-all and cycle. |
| 14:11 | mk | TimMc: I was wondering about other ways of implementing the functions given above |
| 14:11 | TimMc | &(let [m 3] (partition 2 1 [0] (range m))) |
| 14:11 | lazybot | ⇒ ((0 1) (1 2) (2 0)) |
| 14:13 | mk | well that was easy |
| 14:13 | joegallo_ | mk: not like that exactly... |
| 14:13 | joegallo_ | ah, woops, failed to scroll down :) |
| 14:13 | joegallo_ | nevermind |
| 14:17 | mk | that's probably exactly a case that the pad is meant for, though it's not very obvious |
| 14:19 | mk | are (ns-...) all subsets of ns-map? |
| 14:22 | hyPiRion | Unexpected. I didn't know clojure allowed single-quotes in variable-names. |
| 14:23 | hyPiRion | &(dec' 1.01) |
| 14:23 | lazybot | ⇒ 0.010000000000000009 |
| 14:24 | ebaxt | anyone using noir here that can answer a quick question about middleware and noir.util.test? |
| 14:25 | mk | ebaxt: you're in the right place, and if you aren't you'll usually find out by just asking :) |
| 14:29 | ebaxt | mk: well, I'm basically wondering if it's possible to enable middleware when using the send-request-map helper in noir? |
| 14:30 | ebaxt | mk: 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:04 | mk | ,(var? *ns*) |
| 15:04 | clojurebot | false |
| 15:06 | mk | is *ns* a var, or an atom, or? |
| 15:07 | cark | ,(var? #'*ns*) |
| 15:07 | clojurebot | true |
| 15:07 | cark | there is a *ns* var |
| 15:07 | cark | when you use *ns* you get trhe value bound to this var |
| 15:09 | AWizzArd | The four chars ‘*ns*’ make up a symbol. |
| 15:09 | cark | also yes |
| 15:09 | mk | why isn't it an atom? |
| 15:10 | AWizzArd | You can use the special form ‘var’ on a symbol, to resolve it to a var. cark used the reader macro #' instead of var. |
| 15:10 | cark | a symbol is an atom in the lisp sense, but not in the clojure sense |
| 15:10 | AWizzArd | This var is dynamic, and resolves to an instance of the class Namespace. |
| 15:10 | mk | don't know what an atom is in other lisps |
| 15:11 | AWizzArd | In Common Lisp everything that is not a list is an “atom”. |
| 15:11 | cark | vars are references just like atoms, but they have different properties |
| 15:11 | mk | I'm wondering why *ns* is a var, if vars are intended to not be changed |
| 15:11 | AWizzArd | Vars are just another level of indirection. |
| 15:12 | AWizzArd | Because Clojure is a dynamic language, it will not link directly to the objects, but instead to vars. |
| 15:12 | mk | I thought vars were the first level of indirection |
| 15:12 | AWizzArd | At runtime those will be resolved to lookup the “real” reference to the object in RAM. |
| 15:12 | mk | right, much like in javascript |
| 15:13 | AWizzArd | That 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:13 | AWizzArd | This 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:14 | mk | I'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:15 | cark | i think that's because dynamic vars have dynamic (!) scope |
| 15:15 | cark | by binding *ns* to a namespace, you're in the context of this namespace |
| 15:16 | cark | or the implementor is really, i never had to do that |
| 15:16 | mk | what does being in a context mean? |
| 15:16 | AWizzArd | *ns* can only change in a given thread. There are no concurrency problems with it. |
| 15:16 | cark | well it only means that *ns* has a value for the length of the call chain inside the binding form |
| 15:17 | cark | (binding [*ns* some-namespace] (do-stuff)) |
| 15:17 | lancero | is there something in the repl like *print-length* that works for strings? |
| 15:18 | mk | and if it were an atom, it wouldn't get set back to the right value when it came out of the binding? |
| 15:18 | antares_ | lancero: clojure.core/count works for strings |
| 15:19 | cark | mk : mhh i think that could be done, but yes, binding applies to vars |
| 15:19 | lancero | antares_: not sure if I understand. I want something that will limit all strings output to the repl. |
| 15:19 | antares_ | lancero: ah. I don't think there is way to do that but maybe clojure.repl has something. |
| 15:19 | cark | lancero: maybe have a look at pprint, there might be something along those lines in there |
| 15:21 | mk | lancero: you might look at *out*, and see if you can wrap System/out |
| 15:22 | cark | mk : awizzard make a good point, with atoms, you couldn't do a my-binding form, as the value might change in another thread |
| 15:23 | mk | where is *ns* stored then? in the namespace? in the thread? |
| 15:24 | AWizzArd | You can see a dynamic var as: one atom per thread |
| 15:24 | cark | i don't know the implementation details, but sementically one could see it as each thread having its own copy of it |
| 15:24 | AWizzArd | Each thread has its own ‘atom’, its Var. |
| 15:25 | mk | so dynamic = *...* = encapsulated to the thread? |
| 15:25 | AWizzArd | yup |
| 15:26 | mk | I see |
| 15:26 | mk | cark, AWizzArd: thanks |
| 15:26 | mk | are (ns-...) all subsets of ns-map? |
| 15:27 | cark | i don't understand your question |
| 15:27 | lancero | mk: 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:28 | mk | does ns-map return everything that ns-name, ns-publics, etc. return? |
| 15:29 | cark | i don't think so, it only return a name to object map |
| 15:29 | cark | ns-publics must be looking into each of these i think |
| 15:30 | mk | lancero: I thought perhaps the repl used *out* for printing |
| 15:31 | cark | lancero: maybe you could change print-method for strings ... tho this is a bit heavy handed |
| 15:32 | lancero | hmm... ok. well is there any other way prevent slime/emacs from becoming unresponsive when big strings are printed? |
| 15:33 | cark | print smaller string ! =) |
| 15:33 | cark | strings* |
| 15:33 | mk | lancero: don't print big strings? perhaps you could wrap output in some sort of recursively truncating function |
| 15:33 | AWizzArd | lancero: You can try to open the task manager and kill the java.exe |
| 15:34 | cark | or don't use emacs ! |
| 15:34 | lancero | AWizzArd: yeah! that's what I'm trying to avoid :) |
| 15:34 | cark | mhh tho i don't know what other editor is good with clojure these days |
| 15:34 | mk | lancero: what does the output look like? just strings in a list? |
| 15:36 | lancero | mk: if i was carefull enough to notice each time that it might happen i'd just send it to some output file |
| 15:38 | lancero | hmm... but there's got to be some way to tell the repl to just no print out results at all? |
| 15:39 | cark | ,(do (+ 3 2) nil) |
| 15:39 | clojurebot | nil |
| 15:50 | HeadlessClown | are lein 2.x dependencies still supposed to be written to project/libs/ ? |
| 15:50 | ibdknox | HeadlessClown: no |
| 15:51 | HeadlessClown | where art thou? |
| 15:51 | ibdknox | it adds them directly from ~/.m2 |
| 15:52 | HeadlessClown | well now.. there's the little fellas |
| 15:53 | HeadlessClown | thanks! |
| 15:55 | mk | is 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:56 | arohner | mk: 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:56 | arohner | there's no call-cc |
| 15:59 | mk | hmm. Why not, and is there anything similar? |
| 16:00 | seancorfield | HeadlessClown: 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:00 | mk | perhaps 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:01 | cark | i think there would be security issues if the jvm would allow that |
| 16:02 | cark | what do you need tht stack data for ? |
| 16:02 | mk | I 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:04 | cark | a thread is some kind of a state machine, maybe you could make one, then move its state from one thread to the other |
| 16:04 | mk | cark: I was thinking of some sort of pausible repl-initiated task |
| 16:07 | cark | maybe 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:07 | mk | pausable*. I was thinking clojure might have something that allows this, because of binding etc. |
| 16:08 | mk | cark: that seems similar, though I don't think it would work for arbitrary code |
| 16:10 | cark | or 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:11 | cark | manual call with cc |
| 16:11 | mk | what's a trampoline? |
| 16:12 | Bronsa | ,(doc trampoline) |
| 16:12 | clojurebot | "([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:12 | mk | is this new? it's not on the cheatsheet |
| 16:12 | Bronsa | ,(-> #'trampoline meta :added) |
| 16:12 | clojurebot | "1.0" |
| 16:13 | duck1123 | trampoline isn't that popular, because how often do you need to recurse like that? |
| 16:15 | mk | the returned function can use closures, right? |
| 16:17 | duck1123 | you have to use closures, the fns can't take args |
| 16:17 | mk | seems like you could replace any recursive call with a function return, and trampoline it |
| 16:18 | duck1123 | the examples I've seen involved needing to go back and forth between two different fns. Otherwise, why not just invoke the code directly |
| 16:19 | mk | call stack |
| 16:19 | cark | it's usefull for continuation based stuff, when you have a very long call chain |
| 16:20 | mk | cark: why would you need to trampoline those? just to pause? |
| 16:20 | cark | to avoid stack overflows |
| 16:21 | mk | oh, I see you meant what I meant. I thought you meant a recursive function that called many sub-functions, or something |
| 16:21 | cark | i made this little parser combinator, it passes the continuation to each parser for success and for failure |
| 16:22 | cark | so 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:23 | cark | that's where trampoline got usefull for me |
| 16:23 | cark | i bet there are plenty other use cases |
| 16:23 | mk | interesting |
| 16:24 | cark | ... if not very efficient =P |
| 16:24 | cark | i did this, because with a recursive descent parser i woudl get huge stack traces when i got errors at the bottom of it |
| 16:25 | cark | so i wanted small stack traces, hence continuation based |
| 16:30 | duck1123 | how expensive is doall if your sequence is already realized? |
| 16:31 | cshell | is there any way to get lein 2 to put the deps back in lib? |
| 16:32 | duck1123 | cshell: if not, lein pom; mvn dependency:gather-dependencies |
| 16:34 | cshell | how 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:34 | duck1123 | it might be copy- |
| 16:35 | cshell | yeah i think it looks like it based off the docs |
| 16:35 | cshell | duck1123: thanks! I didn't think about doing it that way |
| 16:35 | mk | duck1123: maybe try it out? |
| 16:36 | mk | what happens if I (let [*ns ...] ... ? |
| 16:36 | mk | *ns* |
| 16:37 | cark | you'll have a local *ns* value in no way related to the *ns* var |
| 16:37 | mk | will it be used to resolve things? |
| 16:37 | cark | nope |
| 16:37 | mk | why not |
| 16:38 | cark | because it's only a name at that point, the *ns* symbol is "shadowed" |
| 16:39 | mk | if I (let [*out* ...], then the new out is used for technical background things. So why not *ns*? |
| 16:39 | cark | if you want to temorarily bind another value to *ns* use the bonding form |
| 16:39 | cark | is it? |
| 16:39 | cark | ,(let [*out* :a] (println "hello")) |
| 16:39 | clojurebot | hello |
| 16:39 | mk | don't know, I might be confusing it |
| 16:39 | cark | looks like it isn't |
| 16:40 | mk | what am I thinking of, then? |
| 16:40 | duck1123 | you're thinking of binding |
| 16:40 | cark | (binding [*out* :a] (println "hello")) |
| 16:40 | duck1123 | let is only for the code lexically in the block |
| 16:40 | cark | looks like clojurebot crashed =P |
| 16:41 | duck1123 | ,(binding [*out* :a] (println "hello")) |
| 16:41 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.io.Writer> |
| 16:41 | cark | oh forgot the comma ! |
| 16:41 | cark | =) |
| 16:42 | duck1123 | it'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:43 | mk | so what's the difference between let and binding? |
| 16:43 | cark | so : let is lexically scoped, binding is dynamically scoped |
| 16:43 | mk | I don't think I understand the difference |
| 16:44 | cark | let only works for the text inside those parenthesis around it (let [a value] ...here....) |
| 16:44 | cark | if you call a function (let [a value] (somefunction)), a oes not exist in somefunction |
| 16:44 | cark | *does |
| 16:45 | cark | *ns* is a var, it exists everywhere |
| 16:45 | mk | but what if that function makes reference to a symbol called a? |
| 16:46 | cark | so (binding [*ns* some-value] (some-function)) : *ns* has value some-value in function some-function |
| 16:46 | duck1123 | ,(let [a 1 b (fn [] a)] ((juxt let binding) [a 2] (b))) |
| 16:46 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(NO_SOURCE_PATH:0)> |
| 16:46 | duck1123 | awww |
| 16:46 | cark | mk : let's try it |
| 16:46 | duck1123 | ,(let [a 1 b (fn [] a)] (let [a 2] (b))) |
| 16:46 | clojurebot | 1 |
| 16:47 | duck1123 | ,(let [a 1 b (fn [] a)] (binding [a 2] (b))) |
| 16:47 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:47 | cark | ,(let [f (fn [] (+ 2 a))] (f)) |
| 16:47 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:47 | cark | see the symbol a does not exist |
| 16:47 | cark | ,(let [f (fn [] (+ 2 a))] (let [a 2] (f))) |
| 16:47 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:47 | duck1123 | not dynamic |
| 16:47 | cark | still does not exist |
| 16:47 | duck1123 | this won't work in clojurebot |
| 16:48 | cark | because let only works on the lexical scope it encloses |
| 16:48 | duck1123 | trying to get around the no def rule |
| 16:49 | mk | ,((fn [f] (let [a 1] (f)) (fn [] (a)) |
| 16:49 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 16:49 | mk | ,((fn [f] (let [a 1] (f)) (fn [] (a))) |
| 16:49 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 16:49 | mk | ,((fn [f] (let [a 1] (f)) (fn [] (a))) |
| 16:49 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 16:50 | mk | I give up, I didn't even add another paren that time |
| 16:50 | mk | ,((fn [f] (let [a 1] (f)) (fn [] (a)))) |
| 16:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:50 | duck1123 | stupid sandboxes not letting me do stuff. failed on cljbin as well, http://cljbin.com/paste/500c6722e4b0f700d2d474b5 |
| 16:50 | mk | ,((fn [f] (binding [a 1] (f)) (fn [] (a)))) |
| 16:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:50 | cark | (let [a 1] (f)) <- that's where a is defined |
| 16:50 | cark | outside of it, you're out of the lexical scope |
| 16:51 | cark | there is much literature on the web about lexical vs dynamic scope |
| 16:51 | duck1123 | cark: 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:51 | mk | I'm under the impression that (fn [] (a)) should be ok if it is executed where a exists |
| 16:52 | amalloy | mk: it has to be compiled to know where to look for a |
| 16:52 | cark | duck1123: i was expecting these errors, making a point for mk |
| 16:52 | duck1123 | The point is lexical scope is tha actual text of the code, dynamic scope is all the code of all the fns called |
| 16:52 | amalloy | duck1123: you could do this in the bots, using ##(doc with-local-vars) |
| 16:52 | lazybot | ⇒ "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:53 | duck1123 | amalloy: good to know. |
| 16:56 | mk | so when a function containing a symbol is compiled, the symbol is just replaced with a reference to whatever it refers to, or? |
| 16:58 | cark | i 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:59 | cark | then* then* |
| 16:59 | cark | looks like my keyboard is really dying =( |
| 17:00 | mk | ,((fn [] (a))) |
| 17:00 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:01 | mk | so at compile time? How can I use a symbol that might not be bound to anything? |
| 17:01 | cark | what would you use it for ? |
| 17:01 | mk | ,((fn [] (*out*))) |
| 17:01 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.io.StringWriter cannot be cast to clojure.lang.IFn> |
| 17:01 | cark | ,(name 'a) |
| 17:01 | clojurebot | "a" |
| 17:02 | cark | ,(name (quote a)) |
| 17:02 | clojurebot | "a" |
| 17:02 | cark | (quote a) |
| 17:02 | cark | ,(quote a) |
| 17:02 | clojurebot | a |
| 17:02 | cark | ,(type (quote a)) |
| 17:02 | clojurebot | clojure.lang.Symbol |
| 17:02 | mk | cark: I'm thinking of how print uses the value of *out* |
| 17:03 | cark | well *out* is not just a symbol, it's a var |
| 17:03 | amalloy | mk: *out* is defined in clojure.core. it's not some magic var that gets made up |
| 17:03 | cark | ,(type *out*) |
| 17:03 | clojurebot | java.io.StringWriter |
| 17:04 | mk | what if pr was defined before *out* was defined? |
| 17:04 | amalloy | wouldn't work |
| 17:04 | cark | nothing magic about it, it was defined somthing like this : (def *out* (StringWriter. ....)) |
| 17:04 | amalloy | binding gives it a new value, but a var has to be defined/declared to tell functions where to look for the current value |
| 17:04 | Bronsa | you could declare it and define it later |
| 17:04 | mk | what if *out* was deleted (or changed) after pr was defined? |
| 17:04 | amalloy | mk: try it and see |
| 17:05 | cark | we did try it (binding [*out* 1] (println "hello")) -> println throws an error |
| 17:05 | mk | don't know how to delete and don't have a handy repl besides bot |
| 17:06 | mk | cark: that's because pr expects out to be a printwriter, not a number |
| 17:06 | amalloy | cark: he wants to destroy the var, not give it a new value |
| 17:06 | cark | i don't want ot test that in my repl ! |
| 17:07 | cark | ns-unmap might do the trick |
| 17:07 | amalloy | i'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:07 | cark | but i guess the reference to the var will keep it alive, and prevent garbage colletion |
| 17:08 | cark | hum i'm pretty sure you can unmap everything |
| 17:08 | mk | ,(ns-unmap *ns* '*out*) |
| 17:08 | clojurebot | nil |
| 17:09 | cark | ,(println "yoh") |
| 17:09 | clojurebot | yoh |
| 17:10 | cark | bots are not a good playground for this kind of stuff |
| 17:10 | cark | besides you would need to unmap it from clojure.core |
| 17:12 | mk | so once a var is referenced, it can never be unmapped? |
| 17:12 | cark | i don't know |
| 17:13 | mk | *out* |
| 17:13 | mk | ,*out* |
| 17:13 | clojurebot | #<StringWriter > |
| 17:13 | mk | I got a repl up and got similar results |
| 17:16 | mk | amalloy is correct it seems |
| 17:17 | mk | if I defn and make reference to foo in function f, (ns-unmap foo) fails until I unmap the function f |
| 17:19 | Raynes | Why are we talking about destroying vars? |
| 17:19 | Raynes | What have they ever done to us? |
| 17:19 | cark | plus they're so cute |
| 17:36 | cshell | does anyone know what text editor/repl cemerick uses? |
| 17:36 | brehaut | everything but emacs |
| 17:37 | Raynes | He uses Eclipse. |
| 17:37 | Raynes | I also got him to use Vim. Not sure if he still does. |
| 17:40 | cshell | ah cool, thanks guys |
| 17:41 | cshell | I 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:42 | cshell | first time i've been disappointed with jetbrains |
| 17:45 | ticking | how is one supposed to debug something without line numbers or function names? |
| 17:45 | ivan | Clojure provides both |
| 17:46 | ticking | ivan, how so? the only thing it spits at me is ClassCastException java.lang.Boolean cannot be cast to clojure.lang.Symbol |
| 17:46 | ticking | and a unusable compiler stack trace |
| 17:46 | ticking | (pst) isn't of much help either |
| 17:47 | emezeske | ticking: pastebin? |
| 17:47 | ticking | emezeske, there you go https://gist.github.com/3161113 ^^ |
| 17:49 | emezeske | ticking: What's this hook.core thing? |
| 17:50 | ivan | whatever is calling alias is passing a boolean instead of a symbol for the first arg |
| 17:50 | mk | why doesn't clojure just map symbols to values? it seems to map symbols to vars, and the value of the var can change |
| 17:50 | emezeske | ticking: 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:50 | ticking | emezeske main namespace of my app (hook was just a quick thing I came up with not after callback but peter pans arch enemy ^^) |
| 17:50 | brehaut | it looks like you need to refer-clojure 'load or change your def |
| 17:51 | ticking | emezeske, no evaling |
| 17:52 | ivan | ticking: can you paste your code from hook that does the require? |
| 17:52 | ticking | brehaut, load is overriden in another napespace |
| 17:53 | brehaut | ticking: loading a clojure namespace / source file will result in some code being evaled, even if you arent calling 'eval' yourself |
| 17:53 | ticking | ivan there you go :) https://gist.github.com/3161129 |
| 17:54 | ticking | here's the entire code of the core file https://gist.github.com/3161132 |
| 17:54 | brehaut | ticking: does hook.image refer-clojure? |
| 17:55 | ticking | brehaut, hm? |
| 17:55 | ticking | https://gist.github.com/3161135 |
| 17:58 | brehaut | oh, 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:59 | ticking | brehaut, ah thanks for that ^^, yeah the error is the problem |
| 18:04 | ticking | so I assume you guys gave up as well ;) |
| 18:05 | brehaut | ticking: 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:05 | ticking | brehaut, thats rediculous, why isn't the compiler showing a line or even just the function, it should have that information somewhere at least |
| 18:06 | ticking | I mean I hope it knows whiich funcitons it compiles |
| 18:07 | brehaut | i generally it does. this appears to be an edge case |
| 18:08 | ticking | brehaut, I don't belive you ;P |
| 18:09 | brehaut | you can belleve whatever you wish. it doesnt change facts |
| 18:09 | emezeske | ticking: 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:11 | ticking | emezeske, 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:20 | brehaut | ticking: thats the trade off you make for considering a relatively young language |
| 18:21 | ticking | brehaut 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:22 | Raynes | I wish more people would tell us how to fix Clojure. |
| 18:23 | emezeske | ticking: So use the erlang vm lisp? |
| 18:23 | socksandsandals | Raynes: lol |
| 18:23 | brehaut | at v 1.4 the language is approximately 5 years old. erlang is ballpark 20 years old. |
| 18:23 | Raynes | brehaut: He is talking about Joxa. |
| 18:23 | socksandsandals | brehaut: 25 this year |
| 18:24 | Raynes | I think. |
| 18:24 | ticking | emezeske, considered, not an option, universities can barely accept clojure because its ontop of java |
| 18:24 | ibdknox | wat |
| 18:24 | muhoo | brain asplodes |
| 18:24 | ibdknox | Most universities teach Java... |
| 18:25 | ticking | ibdknox, ever tried to get a lisp project through in a traditionally oo/impertive environment? |
| 18:25 | ibdknox | ticking: lol |
| 18:25 | ticking | ibdknox, yeah thats why clojure is barely accepted^^ |
| 18:26 | emezeske | ticking: Use java. It's mature. |
| 18:26 | brehaut | err, universities are one of the two strongholds of functional programming |
| 18:26 | ibdknox | yeah |
| 18:26 | ibdknox | I'm confused |
| 18:26 | brehaut | (along with the financial sector) |
| 18:26 | ticking | brehaut, in _some_ departments yes ^^, the rest no chance |
| 18:26 | socksandsandals | I don't understand Joxa |
| 18:26 | ibdknox | ticking: you must be talking about a specific university? |
| 18:26 | socksandsandals | BEAM is barely acceptable as a VM for Erlang |
| 18:27 | muhoo | i'm barely accepting this argument. |
| 18:27 | ticking | brehaut, but 5 years is a lot of time to get error messages right ^^ |
| 18:28 | ibdknox | ticking: I don't think anyone would argue Clojure's error messages should be better |
| 18:28 | Raynes | But it isn't like they're useless. |
| 18:28 | ibdknox | right |
| 18:28 | Raynes | If you spend 10 minutes learning to read a stacktrace. |
| 18:28 | Raynes | It does give you line numbers. |
| 18:28 | Raynes | Even hints around at what the issue is occasionally. |
| 18:29 | socksandsandals | I'm pretty new to Clojure and I don't find them too difficult to understand |
| 18:29 | ibdknox | moreover, 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:29 | emezeske | ticking: 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:29 | Raynes | I'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:30 | mk | why doesn't clojure just map symbols to values? it seems to map symbols to vars, and the value of the var can change |
| 18:30 | cark | gfredericks: whatwhatwhat ? |
| 18:31 | gfredericks | mk: believe it or not that was intentional |
| 18:31 | ticking | emezeske, 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:31 | kreig1 | blah blahb lah |
| 18:31 | ibdknox | ticking: what's your background? |
| 18:31 | socksandsandals | ticking: I assume you're at CMU? |
| 18:31 | kreig1 | I have no problem debugging my 20k lines of clojure |
| 18:31 | kreig1 | or before that 50k lines of CL |
| 18:31 | Raynes | There are stacktraces. |
| 18:32 | ticking | ibdknox, common/pico-lisp, io, self |
| 18:32 | brehaut | ticking is complaining because he hit an edge case |
| 18:32 | ticking | socksandsandals, nope germany |
| 18:32 | brehaut | the stack trace is less helpful than normal |
| 18:32 | cark | kreig1: well to tbh CL's error system is top notch |
| 18:32 | mk | why was it intentional? |
| 18:32 | kreig1 | file an issue in JIRA |
| 18:32 | gfredericks | mk: because it is quite useful; also note that not all symbols refer to vars |
| 18:33 | kreig1 | cark: and restarts 8) |
| 18:33 | cark | kreig1: hehe yes good stuff |
| 18:33 | ticking | brehaut, Raynes, reminds me of pauls old "Programming languages teach you not to want what they cannot |
| 18:33 | ticking | provide." |
| 18:33 | mk | right, some refer to special forms, but that's fine, because you just check the special form map before checking the namespace map, no? |
| 18:33 | kreig1 | cark: 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:34 | brehaut | ticking: 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:34 | mk | in what cases is it useful? |
| 18:34 | kreig1 | cark: that said, no problem debugging in clisp |
| 18:34 | gfredericks | mk: also you have interop symbols and locals |
| 18:34 | cark | kreig1: i was using lispworks, it was good |
| 18:34 | socksandsandals | how much is Franz these days? |
| 18:34 | gfredericks | mk: it's useful when you want to redefine something |
| 18:34 | ticking | brehaut, exactly! protocols is nice but it is not fundamental, the basics should be right before you start with bells and whistles |
| 18:35 | kreig1 | ticking: then fix them |
| 18:35 | Raynes | Do what everyone else does and write your own language. Obviously this one is all wrong. |
| 18:35 | brehaut | ticking: go use another language then |
| 18:35 | kreig1 | ticking: really, we're a bit busy working to deal with trolls |
| 18:35 | ibdknox | ticking: you hit an edge case, I'm not sure I understand why you're complaining. Sounds like you found a bug |
| 18:35 | kreig1 | except on sunday, which is troll day |
| 18:35 | kreig1 | yah: I say file it in JIRA |
| 18:35 | mk | gfredericks: locals are created through let? how do they work now? I expect that all that is handled before ns is touched, no? |
| 18:35 | ibdknox | ticking: Stacktraces in Clojure are generally useful |
| 18:36 | ibdknox | ticking: things can always be better, but it's far form the dire situation you seem to be painting |
| 18:36 | cark | mk : locals are just like in any other language, like in java, only read-only |
| 18:36 | cark | or final really |
| 18:37 | gfredericks | mk: 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:37 | ticking | ibdknox, I jsut stating as I experienced it, every error message I encountered was pretty useless |
| 18:37 | ibdknox | ticking: and this is your first use of Clojure? |
| 18:37 | cark | ticking: they're good enough for me to find problems |
| 18:38 | ibdknox | ticking: have you ever read a Java stacktrace? |
| 18:38 | ticking | ibdknox, pretty mutch wanted to use a lisp had to use something that works in "corporate environments" aka java |
| 18:38 | ticking | ibdknox, yeah java was my first language |
| 18:38 | cemerick | cshell: Eclipse + Counterclockwise for everything Clojure |
| 18:38 | clojurebot | clojure > scheme |
| 18:38 | cemerick | as well as most javascript, HTML, and CSS |
| 18:39 | ibdknox | ticking: can you give examples of the errors you found useless? |
| 18:39 | cemerick | macvim for miscellaneous non-project-related bits |
| 18:39 | brehaut | ibdknox: https://gist.github.com/3161113 |
| 18:39 | cark | cemerick: what's the current status of counterclockwize, as compared to slime ? |
| 18:39 | mk | gfredericks: 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:39 | brehaut | ibdknox: his code is https://gist.github.com/3161132 |
| 18:39 | ticking | ibdknox, 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:40 | cemerick | cark: very, very approximately, they're largely equivalent. |
| 18:40 | ibdknox | ticking: sure, this is one example - you implied there were many? |
| 18:40 | gfredericks | mk: if they're locals that's not true |
| 18:40 | cemerick | There are some features that each has that the other doesn't, but there's a ton of overlap. |
| 18:40 | socksandsandals | seems pretty clear to me: you redefined "load" |
| 18:40 | mk | gfredericks: right - so there'd be a stack of maps that it checks before hitting *ns* |
| 18:40 | brehaut | socksandsandals: nah, thats the warning. theres a cast error immediately below that |
| 18:41 | cark | cemerick: thanks i'll look into it again |
| 18:41 | socksandsandals | brehaut: oic |
| 18:41 | brehaut | socksandsandals: i made the same mistake |
| 18:41 | gfredericks | mk: so otherwise that sounds essentially correct |
| 18:41 | ticking | ibdknox, 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:41 | Bronsa | is the (:require hook.image :as image) right? |
| 18:42 | emezeske | I... I just... |
| 18:42 | mk | so why does *ns* return a var, which contains the value, instead of just returning the value? |
| 18:42 | cemerick | cark: Best to start with the betas track. Official releases are ~monthly maybe, betas go out ~weekly. |
| 18:42 | emezeske | Complaining does not help. Helping helps. |
| 18:42 | cark | mk : what you're saying is conceptually correct, tho it's not how it actally works i suspect |
| 18:42 | ibdknox | Bronsa: no it isn't - that's what's blowing up |
| 18:42 | cark | cemerick: will do |
| 18:42 | Bronsa | ibdknox: yeah, i meant, that's the problem |
| 18:43 | mk | cark: 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:43 | cark | mk : when you use *ns* in some call, what you get is the value bound to that var, not the var itself |
| 18:43 | mk | (I assume there's a good reason) |
| 18:43 | gfredericks | mk: do you agree that it's good to be able to change the value of a def'd name? |
| 18:43 | cark | so you're wrong there |
| 18:44 | cark | ,(type *ns*) |
| 18:44 | clojurebot | clojure.lang.Namespace |
| 18:44 | cark | see that's not a var, that's a namespace |
| 18:44 | mk | cark: I'm not talking about *ns*, but using it to refer to "the current namespace" |
| 18:44 | ibdknox | ticking: 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:44 | ticking | ibdknox, yeah that was it thanks, but where did the boolean come from? |
| 18:44 | mk | gfredericks: yeah but can't clojure do that through curNS.put("foo", newval)? |
| 18:45 | ibdknox | ticking: 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:45 | gfredericks | mk: so let's make sure we're distinguishing what time things happen |
| 18:45 | ibdknox | ticking: I'm not sure to be honest |
| 18:46 | ticking | ibdknox, oh boy ^^ |
| 18:46 | gfredericks | you're saying that at compile-time the compiler emits *ns*.get('foo'), and at runtime *ns*.get('foo') is called, right? |
| 18:47 | cark | mk: what are you trying to do, and what is your concrete problem ? |
| 18:47 | mk | ok, good - no, I'm saying that at compile time the compiler emits symbol foo, and at runtime the symbol is evaluated |
| 18:47 | mk | cark: "understand clojure" :) |
| 18:47 | kreig1 | hehe |
| 18:47 | cark | only one way to do that, pick a project, work on it, make a mental model about it |
| 18:48 | kreig1 | ticking: intersting, never seen the (seesaw core .. form of an argument to :use |
| 18:48 | ibdknox | ticking: 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:48 | gfredericks | cark: surely asking questions isn't never appropriate |
| 18:48 | ibdknox | ticking: 5 years is not a long time to get something *completely* right :) |
| 18:48 | ibdknox | since you can't even know what right is, even 5 years in |
| 18:49 | cark | gfredericks: sure, but we've been going at it for a long while now, and i feel we hit a road-block |
| 18:49 | cark | i might be wrong tho |
| 18:49 | riley526 | Noob 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:49 | gfredericks | oh I just jumped in |
| 18:49 | riley526 | When I stringify the whole request, it looks just like a map. But (map? ring-request) returns false. |
| 18:49 | ibdknox | riley526: ring request is a fn |
| 18:50 | ibdknox | that returns a map |
| 18:50 | ibdknox | riley526: (:request-method (ring-request)) |
| 18:50 | gfredericks | mk: 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:50 | riley526 | ibdknox: WHAT... are you serious... I wasted way too much time last night on that. Haha. |
| 18:51 | riley526 | ibdknox: Thank you very much. I guess the docs didn't make that clear enough to me. |
| 18:51 | ibdknox | hm |
| 18:51 | ibdknox | riley526: http://webnoir.org/autodoc/1.3.0/noir.request.html#var-ring-request - do you have suggestions? |
| 18:51 | mk | cark: some questions lead to others, and if things are stuck, which I don't think they are, a new person can often help |
| 18:52 | cark | true |
| 18:52 | ticking | ibdknox, 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:53 | riley526 | ibdknox: Actually, no. It seems perfectly clear now. "Returns back the current ring request map" is really obvious. |
| 18:53 | riley526 | ibdknox: I just had noob blinders on. |
| 18:53 | kreig1 | ticking: I still think your being a bit dickish with this assertion that error messages don't work |
| 18:54 | ticking | ibdknox, 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:54 | mk | gfredericks: 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:54 | kreig1 | ticking: because the experience o alot of other people don't back that up |
| 18:54 | kreig1 | ticking: I find it's the errors in special forms that are the worse |
| 18:54 | kreig1 | ticking: like the ns error you ran into |
| 18:54 | cark | mk : but you're not exposed to vars unless you do some pretty advanced namespace stuff |
| 18:54 | ibdknox | ticking: 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:55 | kreig1 | ticking: it's one reason also why you lose compiler and useful line info |
| 18:55 | ticking | kreig1, 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:55 | cark | mk : just (def stuff ... or (defn stuff, and there you go, code away, never thinking about vars |
| 18:56 | ibdknox | ticking: 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:56 | kreig1 | ticking: yah, so? |
| 18:56 | cark | just like in javascript you don't really need to know objects are also maps unless you're doing pretty dvanced stuff |
| 18:56 | gfredericks | mk: another problem with your model is that it doesn't account for (:use) and (:require) |
| 18:57 | cark | (fior some value of advanced) |
| 18:57 | ibdknox | ticking: the reason why is largely that it falls in a weird space implementation-wise |
| 18:57 | kreig1 | ticking: in your case, was the erorr in the ns form for you? |
| 18:57 | ticking | kreig1, so it seems to me that they are a known cause for hassle, yeah it was |
| 18:57 | ticking | ibdknox, yeah I'll finish this small project and see how the other messages behave ^^ |
| 18:57 | mk | ticking: 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:58 | kreig1 | ticking: which line was it? |
| 18:58 | kreig1 | ticking: i'm trying to reproduce a similiar error here |
| 18:58 | ticking | kreig1 2 |
| 18:58 | kreig1 | mk: we don't want him to drop it 8) |
| 18:59 | mk | kreig1: this much seems obvious ;) |
| 18:59 | kreig1 | ticking: ah, the fact that you didn't make a refspec [foo :as bar] |
| 18:59 | ticking | yeah |
| 18:59 | kreig1 | and since it all is in the form on "line 1" it tells you it's in the ns form, but not which part |
| 19:00 | mk | gfredericks: you'd just put a map under *ns* with those mappings that is checked when ns returns null |
| 19:00 | ticking | kreig1, 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:01 | mk | err, sorry, that wouldn't allow changes. I mean a map from symbol to the namespace that should be checked for that symbol. |
| 19:01 | ticking | kreig1, but srsly java.lang.Boolean cannot be cast to clojure.lang.Symbol, is just wat ^^ |
| 19:02 | kreig1 | uhm |
| 19:02 | kreig1 | reading that stack trace tells me exactly where the problem is |
| 19:02 | kreig1 | as someone familiar with core.clj |
| 19:03 | kreig1 | literally, you can figure out what it is from there |
| 19:03 | mk | the 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:03 | kreig1 | tciking: but I totally agree |
| 19:03 | kreig1 | ticking: and while that is the correct error and you can decipher it from reading a stack |
| 19:03 | kreig1 | ticking: what shuld happen, is that the ns form should catch that badly formed :require line |
| 19:04 | ticking | kreig1, where is the line you see it in the st at hook.core$eval5$loading__4505__auto____6.invoke(core.clj:1) ? |
| 19:04 | kreig1 | ticking: and give you a more explicit error, earlier, and not later when it tries to make an alias |
| 19:05 | kreig1 | the core.clj:5352 line (that's incside (require |
| 19:05 | kreig1 | ticking: open up core.clj and chck it out |
| 19:05 | kreig1 | sorry, I'll slow down and type better... |
| 19:05 | ticking | kreig1 currently skimming through it ^^ |
| 19:06 | kreig1 | ticking: it's calling load-libs on a list '(hook.image :as image) |
| 19:07 | ticking | kreig1, ah right now I see the corresponding require call in the pst |
| 19:07 | kreig1 | ticking: 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:08 | mk | why is it a bad idea to allow (fn [] (foo)), where foo has not been defined? |
| 19:10 | ticking | kreig1, possible, but this just catches a very specific border case (forgotten []), doesn't it? |
| 19:10 | siscia | newbie 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:11 | kreig1 | ticking: yah, but that's the correct place to catch it iMO |
| 19:12 | mk | siscia: is equals implemented correctly? |
| 19:12 | siscia | mk, i am not sure... |
| 19:13 | kreig1 | ticking: the fact that it's a Boolean cannot be cast to Symbol that blows up is indeed esoteric |
| 19:13 | siscia | (equals [this other] (= (:name this) (:name other))) |
| 19:13 | kreig1 | ticking: but the stacktrace does tell you where it happend 8^) |
| 19:13 | mk | siscia: how is hashcode implemented? |
| 19:13 | emezeske | siscia: 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:14 | siscia | (.hashCode (:name this)) |
| 19:14 | kreig1 | ticking: the call to (alias as lib) in load-lib, I bet it's passing a null or false as the lib argument |
| 19:14 | ticking | kreig1, yeah it kinda does^^ gruesome long sts is probably something clojure inherited form java, I wonder why the pst form isnt the default ^^ |
| 19:14 | emezeske | siscia: I'm not certain if a buggy equals could cause the exception you saw |
| 19:14 | kreig1 | ticking: pst form? I'm lost |
| 19:14 | ticking | (pst) |
| 19:15 | emezeske | siscia: Is (:name this) an integer? |
| 19:15 | ticking | kreig1, the form it prints when you use the repls? pst funciton |
| 19:15 | siscia | no it's a key |
| 19:15 | siscia | emezeske, no it is a key |
| 19:15 | emezeske | siscia: Isn't .hashCode supposed to return an integer? |
| 19:16 | siscia | emezeske, is not a string... |
| 19:16 | emezeske | siscia: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Object.html#hashCode() |
| 19:16 | kreig1 | ticking: well pst would have not told you where the bug was actually |
| 19:16 | emezeske | siscia: I think hashCode has to return an int. |
| 19:16 | kreig1 | ticking: it would have said "somewhere in the ns form" |
| 19:16 | mk | siscia: ^ the hash with 89735 to not conflict strings |
| 19:16 | kreig1 | throwing info OUT o the stacktrace IMO, is shitty |
| 19:16 | ticking | kreig1, yeah that's something I'm completely happy with ^^ |
| 19:16 | siscia | yeah you are right |
| 19:17 | kreig1 | ticking: no way |
| 19:17 | siscia | emezeske, but it does... |
| 19:17 | ticking | kreig1, well yeah but only if you don't have a non-default way to show more ^^ |
| 19:17 | emezeske | siscia: Oh, one other rule: .hashCode needs to depend on all of the fields that might affect .equals |
| 19:18 | kreig1 | ticking: I see that as your UIs job, not the runtime |
| 19:18 | siscia | emezeske, it does |
| 19:18 | emezeske | siscia: Hah, I got nothing then :) |
| 19:18 | kreig1 | ticking: cause if I get a stacktrace someplace in my app, I want to see the whole fucking thing in my log |
| 19:18 | ticking | kreig1, point accepted^^ |
| 19:18 | kreig1 | cause, I can't reproduce it easily |
| 19:18 | kreig1 | ticking: but let's take this someplace productive |
| 19:19 | kreig1 | ticking: 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:19 | siscia | emezeske, https://gist.github.com/3161358 |
| 19:19 | kreig1 | ticking: cause everyone uses namespaces, and I'm sure everyone makes this same mistake |
| 19:19 | ticking | kreig1, possible ^^ |
| 19:20 | emezeske | siscia: Looks reasonable to me. I don't do a whole lot with deftype, though, so I won't be much help :( |
| 19:21 | siscia | emezeske, thanks anyway... |
| 19:21 | kreig1 | ticking: you using 1.3.0? |
| 19:21 | ticking | kreig1 1.4.0 |
| 19:22 | kreig1 | ticking: let me pull that down |
| 19:22 | siscia | my point is that i need something that given an identical field would be the same in a set... |
| 19:22 | kreig1 | ticking: my CA letter should have been received by now, let's make a patch for this |
| 19:23 | kreig1 | ticking: hah, 1.4.0 ns is pretty much the same as 1.3.0 |
| 19:24 | mk | siscia: hashsets use hashcode and equals, treesets use comparable |
| 19:24 | mk | siscia: usually if there are fields not factored into equals, they... shouldn't be there |
| 19:26 | siscia | mk, sorry i wasn't clear... I was talking about hashset |
| 19:26 | kreig1 | ticking: hah, looks like you could invoke any clojure.core fn you want in an (ns .. form |
| 19:26 | kreig1 | tciking: look at core.clj:5117 |
| 19:27 | ticking | kreig1, in condp? |
| 19:27 | siscia | mk, yeah I see what you mean... but i need both field and only one must be unique |
| 19:28 | ticking | kreig1, oh sorry followed a bad google link and got a bad code revision ^^ |
| 19:28 | kreig1 | ticking: hmm, no this is in the (defmacro ns form in clojure core.clj 8) |
| 19:29 | kreig1 | basically it takes the keyword (:require, looks it up in clojure.core and invokes it on that args |
| 19:30 | kreig1 | user> (ns foo (:print "HARuser> (ns foo (:print "HARHAR")) |
| 19:30 | kreig1 | HARHARnil |
| 19:30 | kreig1 | ,(ns foo (:load "foo.clj")) |
| 19:30 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate foo.clj__init.class or foo.clj.clj on classpath: > |
| 19:30 | ticking | kreig1, oh right, 0o |
| 19:30 | kreig1 | haha |
| 19:31 | kreig1 | hmm, go try that on some of the "try clojure" websites |
| 19:31 | kreig1 | wonder if you can bypass their attempts at restricting your evaluation namespace |
| 19:31 | ticking | lol |
| 19:31 | ticking | wonder what clojurebot thinks of this ^^ |
| 19:31 | kreig1 | see the runtie exception? |
| 19:33 | ticking | lol |
| 19:33 | kreig1 | ok, so we might wanna put that check in the macro expander 8) |
| 19:34 | kreig1 | err, I should get a proper checkout of clojure for this, gimme a minute |
| 19:34 | ticking | this is what tryclj says about itClojure> (ns foo (:load "foo.clj")) |
| 19:34 | ticking | java.lang.SecurityException: You tripped the alarm! class clojure.lang.Compiler is bad! |
| 19:34 | mk | siscia: try creating a new Node on its own |
| 19:34 | kreig1 | oh sweet |
| 19:34 | kreig1 | good on them |
| 19:35 | siscia | mk, I was trying right now and it weird... Because it give me "Evaluation Aborted"... |
| 19:35 | kreig1 | ticking: 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:36 | ticking | kreig1, I'll see what I can do ^^ |
| 19:36 | kreig1 | and (throw (new Exception ... |
| 19:37 | kreig1 | nice part about largely self-hosting lisps 8) |
| 19:38 | siscia | ,(deftype Node [name table] Object (equals [this other] (= (:name this) (:name other))) (hashCode [this] (.hashCode (:name this))) |
| 19:38 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 19:38 | siscia | ,(deftype Node [name table] Object (equals [this other] (= (:name this) (:name other))) (hashCode [this] (.hashCode (:name this)))) |
| 19:38 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 19:39 | siscia | Sorry about that... |
| 19:41 | ticking | kreig1, looks like all the work is done by load-libs, which seems to also handle :use |
| 19:42 | gfredericks | mk: 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:42 | kreig1 | ticking: yup |
| 19:43 | kreig1 | ticking: however, require/use are the user facing interfaces for that |
| 19:43 | kreig1 | ticking: so I'm inclined to put any error checking in there |
| 19:43 | ticking | kreig1, sounds reasonable |
| 19:43 | kreig1 | ticking: because if you look at load-lib, it's API is kinda complex |
| 19:44 | kreig1 | and, having it throw an error, it doesn't know which user facing func was called |
| 19:44 | ticking | kreig1 yeah |
| 19:44 | kreig1 | ticking: It could raise an error, ":as is not a valid library name" or something like that |
| 19:44 | kreig1 | ticking: but won't help much |
| 19:44 | kreig1 | ticking: only slightly less opaque than Bool can't be shoved into Symbol hole |
| 19:45 | kreig1 | ,(ns foo (:print "I AM A ROBOT!")) |
| 19:45 | clojurebot | I AM A ROBOT! |
| 19:46 | ticking | kreig1, thats a really weird implementation side effect |
| 19:47 | kreig1 | yah 8) |
| 19:47 | mk | gfredericks: perhaps something to do with importing functions from other namespaces? |
| 19:47 | kreig1 | hahaha |
| 19:50 | gfredericks | mk: no, I think that would all work using the imports map you mentioned |
| 19:51 | amalloy | gfredericks, mk: if you allow symbols which aren't defined, the compiler can't give you error messages early |
| 19:51 | amalloy | you're playing around at the repl and you (defn foo [] (princ 1)) |
| 19:51 | gfredericks | amalloy: presumably not ever, since eval is allowed at runtime |
| 19:51 | amalloy | it can't complain that you forgot what lisp you're in, because maybe you're planning to define princ later |
| 19:52 | kreig1 | ticking: I gotta run an errand, I am reachable at craig@red-bean.com and will be back later. |
| 19:52 | mk | gfredericks: 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:52 | kreig1 | ticking: let's put some patches together and contribute them |
| 19:52 | ticking | sure, I think I'll hit the hay for a few hours too, its 2am here in germany ^^ |
| 19:52 | gfredericks | mk: importing shouldn't have anything to do with evaling |
| 19:53 | gfredericks | amalloy: do you if there's anything semantically wrong with the varless model of symbol compilation we've been talking about? |
| 19:53 | ticking | kreig1, I'll see where I can help as I'm pretty new to clojure ^^ |
| 19:53 | amalloy | i dunno, i haven't been listening |
| 19:53 | mk | gfredericks: 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:53 | ticking | kreig1, but I'm sure it'll be fun see you later and good luck :D |
| 19:54 | gfredericks | mk: not in my head |
| 19:54 | kreig1 | ticking: judging by your background, I think tightening up use/require is well without your grasp |
| 19:54 | kreig1 | ticking: within 8) |
| 19:54 | ticking | hrhr |
| 19:55 | mk | gfredericks: 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:55 | gfredericks | yep |
| 19:56 | kreig1 | ticking: the hard part, is that you have to use only the stuff already define in core.clj 8) |
| 19:56 | ticking | kreig1, ah I see, sounds interesting |
| 19:57 | mk | amalloy: 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:57 | ticking | kreig1, so the smaller the line number of the functions head the harder it is to write |
| 19:57 | kreig1 | in this case, perhaps *) |
| 19:58 | kreig1 | althoughy ou basically have most of the list opertions and such |
| 19:58 | ticking | kreig1, ah ok ^^ |
| 20:02 | mk | gfredericks: 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:03 | mk | just say "clojure looks up symbols in the namespace and other places, though under the hood things are more complicated" |
| 20:07 | haspaker | Good evening |
| 20:09 | Bronsa | is it evening in the US? |
| 20:09 | haspaker | I have absolutely no idea |
| 20:09 | kreig1 | early evening |
| 20:09 | haspaker | Here in Sweden it's in the middle of the night |
| 20:10 | haspaker | What kind of features does Sublime Text need in order to be useful for clojure development? |
| 20:10 | haspaker | I have already fixed the indentation and rainbow parentheses |
| 20:13 | nicholasf | looking 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:13 | nicholasf | has anyone done this? |
| 20:14 | brehaut | nicholasf: seen https://github.com/raynes/tentacles/ ? |
| 20:14 | nicholasf | brehaut: looking now |
| 20:15 | nicholasf | brehaut: this looks really interesting |
| 22:55 | Raynes | nicholasf: 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:57 | nicholasf | Raynes: thanks mate |
| 23:46 | haspaker | Do anyone here know a nice color scheme for clojure on a dark background? |
| 23:47 | wmealing | you'll usually need to discuss which editor |
| 23:49 | clj_newb_28489 | sup wizards of the 1023rd level of clojure |
| 23:49 | clj_newb_28489 | so I'm using clojurescript, trying to setup a clojurescript repl |
| 23:49 | clj_newb_28489 | and I have the exact same piece of code; checked into git |
| 23:49 | clj_newb_28489 | and it works on my dekstop imac, but not my laptop macbook pro |
| 23:49 | clj_newb_28489 | these two machiens have the _exact_ same maven repos, the exact same lein config setups |
| 23:49 | clj_newb_28489 | running the exact same code |
| 23:49 | clj_newb_28489 | they even have the exact same version of chrome |
| 23:50 | clj_newb_28489 | one of them -- I get a clojurescript repl just fine |
| 23:50 | wmealing | errors in the js console ? |
| 23:50 | clj_newb_28489 | the 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:50 | clj_newb_28489 | (I'm using chrome's built in debugging tools) |
| 23:50 | wmealing | if you restart chrome, does it work ? |
| 23:50 | wmealing | (chrome does magical live updates) |
| 23:50 | clj_newb_28489 | then, when I click on those, it brings me into incomprehensible levels of clojurescript code |
| 23:50 | clj_newb_28489 | hmm |
| 23:51 | wmealing | i guess he's on the macbook pro |
| 23:51 | clj_newb_2834020 | clever way to get me to kick myself out of #clojure :-) |
| 23:51 | clj_newb_2834020 | i will now run web chat in safari, and do my code testing in chrome |
| 23:51 | wmealing | totally, right ? |
| 23:51 | wmealing | sorry dude |
| 23:52 | clj_newb_2834020 | Uncaught TypeError: Cannot call method 'call' of undefined repl:1221 Uncaught TypeError: Cannot read property 'client' of undefined |
| 23:52 | clj_newb_2834020 | same error |
| 23:52 | clj_newb_2834020 | when I click on the line, it gets me this line: |
| 23:52 | clj_newb_2834020 | goog.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:52 | clj_newb_2834020 | "Uncaught TypeError: can not call method 'call' of undefined" |
| 23:53 | wmealing | hmm |
| 23:53 | clj_newb_2834020 | clojure Object clojure.browser Object clojure.browser.repl Object clojure.browser.repl.client undefined |
| 23:53 | clj_newb_2834020 | hmm, is clojure.browser.repl.client supposed to be undefined or an object? |
| 23:54 | wmealing | i dont know enough about clojurescript |
| 23:54 | wmealing | it might be a security setting in your browser |
| 23:54 | wmealing | (or addon) |
| 23:54 | wmealing | CrossPageChannel is something to do with javascript executing across different domains, iirc |
| 23:56 | clj_newb_2834020 | i have no extensions installed |
| 23:56 | clj_newb_2834020 | and basically everything is allowed |
| 23:58 | wmealing | only breaks in chrome ? other browsers are fine ? |
| 23:58 | clj_newb_2834020 | doesn't work in safari either |
| 23:59 | wmealing | jvm versoin ? |
| 23:59 | clj_newb_2834020 | installing firefox now |
| 23:59 | wmealing | no, not jvm |
| 23:59 | wmealing | idiot |
| 23:59 | wmealing | should be running the same js engine version |
| 23:59 | clj_newb_2834020 | firefox fails too |