#clojure logs

2010-12-24

00:17rata_how do you guys do to detect unwanted references to old data?
01:02anthony_How would I reference String[].class in clojure? String[]/class doesn't work.
01:06anthony_Sorry, nevermind. I got it working.
02:01sivajaghi all
02:01sivajagdoes anyone knows how i can find list of functions in a namespace?
02:15Raynessivajag: (ns-interns (the-ns 'clojure.core)) will get you a list of all vars in clojure.core. That includes vars that aren't bound to functions though.
02:29sivajagRaynes: thanks
02:29sivajagi can filter out functions
03:01bendlasHey folks
03:02bendlasI had a question about protocols
03:02bendlasthey are supposed to solve the expression problem in a save way
03:03bendlasby allowing independent extensions
03:04bendlasbut when you extend a protocol two times for the same type, the later extension overwrites the former one
03:05bendlasso in effect they do allow monkey patching, only enforcing a proper dispatch to super()
03:06bendlasor am I missing something?
03:11bendlaswouldn't it have been better to make protocol extensions namespace local and importable?
03:12bendlaslike scala does with auto coercions (IIRC)
05:09Gigarobylazy sequences do only work with infinite sequences ?
05:10Gigarobyor I can use it to postpone the evaluation of a finite sequence ?
05:31ejacksonGigaroby: the latter.
05:31Gigarobyejackson, can you give me an example ? all the examples I found was with infinite sequences
05:31Leonidashi, I'm trying to run my application with leiningen, but I fail, since the application needs command line arguments http://paste.pocoo.org/show/309267/
05:32ejackson,(def a (map inc [1 2 3]))
05:32clojurebotDENIED
05:32ejacksonok, it won't let me do a def, but you get the idea
05:32ejacksonmap turns [1 2 3] into a seq
05:32ejacksonand evaluates lazily
05:32Leonidasbut when I say "lein run filename" I get this exception: http://paste.pocoo.org/show/309268/
05:36Leonidaswhat am I doing wrong? it seems lein run does something undesirable to the command line arguments...
05:45Leonidasanyone has an idea what I'm doing wrong with 'lein run filename' ?
05:48ejacksonLeonidas: i really dunno, never used lein, and I think the channel is going to be super quiet over the next few days. Perhaps ask again later when the US wakes up ?
05:49Leonidasejackson: yeah, good idea. I think I'll put the question on the clojure mailing list, so people can answer to if when they are awake :)
05:49ejacksonthere you go
06:11bendlas Leonidas: try `lein run -m namespace-name`
06:12bendlas`lein help run` says
06:12bendlasUSAGE: lein run [ARGS...]
06:12bendlasCalls the -main function in the namespace specified as :main in project.clj.
06:12bendlas
06:12bendlasUSAGE: lein run -m NAMESPACE [ARGS...]
06:12bendlasCalls the -main function in the specified namespace.
06:12bendlas
06:12zvrbaah!
06:12zvrbaa question: is it possible to save an "image" with clojure as it is with CL or R?
06:14bendlaszvrba: not that i know of
06:14zvrba:/
06:16bendlasclojure can't give you more than java (or CIL) bytecode (for now), as far as executable format is concerned
06:16zvrbabut image=code+data
06:16Leonidasbendlas: I already set :main to the namespace, otherwise it wouldn't run in the first place complaining about :main being unset
06:16bendlasand since java doesn't even support precompiled Arrays ...
06:17zvrbacode is already stored in class files, but the working storage COULD be dumped to disk in some way. i guess.
06:17bendlasah ok
06:17bendlasin that case java takes you far enough
06:17bendlasconsider jar's
06:17zvrbawhat about them?
06:18bendlasthey are code+data
06:18zvrbayes
06:18bendlasor you want mutable data?
06:18zvrbahmmm?
06:18zvrbai just want to save all objects currently in memory, exit the interpreter, restart it and have it reload what was there before
06:18bendlaslike writing data into the image to persist state?
06:19bendlasright
06:19zvrbalike.. hm, in CL: (setq *A* 12) .. save image .. exit .. start again .. (+ *A* 15) -> 27
06:19bendlasi bet there is some enterprisey java software for that
06:20zvrbaof course, i'd also like to dump functions i've defined to image
06:20bendlasterracotta
06:20bendlasthat was it
06:20zvrbabut then we get to JVM limitations you mentioned, i guess
06:20bendlasdisregard, terracotta is for IPC
06:21zvrbaok, nothing out of the box is available. thanks :-)
06:22bendlasyw
06:22zvrbawhy do I ask: i'd like to learn a lisp-like language, and I started with common lisp.
06:22zvrbanow i'm looking a bit into clojure.
06:23zvrbai do programming for a living, and I heavily use math
06:23zvrbaso i thought i could use LISP as a calculator
06:23zvrbabut for this i *really* want my session state saved between interpreter runs (many local vars, helper functions, etc)
06:23Leonidaszvrba: common lisp images?
06:23zvrbaLeonidas: what about it?
06:24zvrbaLeonidas: yes, i askes whether there was an equivalent in clojure.
06:24zvrba*asked
06:24Leonidaszvrba: they save state between runs. Oh, I see.
06:24Leonidaszvrba: but if you need that, why don't you stay with CL?
06:24bendlasyou can print and read back all basic datastructs without effort
06:25bendlasand you can walk a namespace
06:26Leonidasthere was a way to freeze processes to disc, at least on linux, maybe you're interested in that?
06:26bendlasLeonidas: read; with -m you run an arbitrary file, it doesn't even look at defined :main
06:27bendlaswithout you give ARGS to defined :main
06:27Leonidasbendlas: so I can't just "lein run ARGS" and run :main with the ARGS?
06:28bendlaslemme check :)
06:28Leonidasbendlas: if you want, I can send you a link to my git repo where I am trying to get it running
06:30bendlassry, i see it now
06:30bendlaslein run -m main args
06:30bendlasworks anyway
06:30Leonidasbendlas: when I use -m namespace ARGS I get this: http://paste.pocoo.org/show/309274/
06:31Leonidasbendlas: \i is probably because by ARGS start with an i letter :/
06:31bendlashmm
06:34bendlas(ns main)
06:34bendlas(defn -main
06:34bendlas ([echo] (println "You said" echo))
06:34bendlasYou said xyz
06:34bendlaslein run -m main xyz
06:35bendlasswap last two lines; works for me
06:36LeonidasException in thread "main" java.io.FileNotFoundException: Could not locate main__init.class or main.clj on classpath: (NO_SOURCE_FILE:1)
06:36Leonidasoh, wait a moment...
06:37bendlasbut the case w/o -m is indeed funky
06:37Leonidasbendlas: ok, *that* works for me as well.
06:39Leonidasbendlas: https://github.com/Leonidas-from-XIV/karmawhore <- please see here. It seems it does weird things to [& args].
06:42bendlas(defn -main
06:42bendlas ([& echo] (println "You said" echo))
06:42bendlas
06:42bendlas% lein run -m main xyz abc def
06:42bendlasYou said (xyz abc def)
06:42bendlasffirst
06:43bendlasgets first character of first arg string
06:44bendlasLeonidas: try
06:44bendlas(defn -main [& args]
06:44bendlas (let [file-name (first args) ...
06:45bendlasinstead of (ffirst args)
06:47Leonidasbendlas: oh, ok, I think I start to understand. So it does not do (-main *command-line-args*) but rather (apply -main *command-line-args*), right?
06:47bendlasand since you don't use (rest args) you might just aswell write
06:47bendlas(defn -main [file-name] ...
06:47bendlasyep
06:48LauJensenbendlas: Why arent you in #clojureql?
06:48bendlasLauJensen: :D
06:48bendlashi
06:48bendlastoo
06:48LeonidasLauJensen: what is #clojureql?
06:48Leonidasbendlas: yeah, the plan was to do some command line parsing later.
06:48LauJensenLeonidas: Its the channel where we discuss development on #clojureql, something which bendlas frequently contributes to
06:49LeonidasLauJensen: oh, ok, thanks :) "ql" didn't sound like development for me.
06:49LauJensenLeonidas: http://github.com/LauJensen/clojureql
06:50Leonidasbendlas: ok, now it runs. Kinda. With -m karmawhore it looks just fine, but without -m, but with a command-line-argument, it tries to load that as a class.
06:51bendlasyes, gotta ask technomancy if that's intended
06:53Leonidasbendlas: thank you!
06:54bendlasyou're welcome
06:55bendlasLauJensen: btw, did you have to do anything special to your clojure-mode, so that it doesn't indent with mixed tabs/spaces
06:55LauJensenbendlas: I have some special indenting settings, but not related to your problem - I recommend reinstalling from scratch, which is what I did recently
06:57bendlasjust did that a week ago, now running on clojure-mode 1.7.1 from elpa
06:58LauJensenIm on 1.8 I think, straight from github
06:58LauJensen1.8.0
06:59bendlaswill try
07:00bendlastabs also suck for mixed emacs/eclipse editing
07:24bendlasoh, there is an untabify command in emacs
07:38bendlashmm lisp-indent-line causes the misbehavior
07:39bendlasLauJensen: could you quickly tell me your
07:39bendlas- M-x version
07:39bendlas- M-: indent-line-function <-- in clojure-mode
07:49bendlasOK, i went with an untabify on save hook as per http://stackoverflow.com/questions/3313210/converting-this-untabify-on-save-hook-for-emacs-to-work-with-espresso-mode-or-al
07:50bendlasfor the records
08:48zvrbabendlas: hm, that with printing/reading back basic data structures is interesting!
08:49zvrba(sorry, i got on-the-door delivery i had to take care of)
08:54bendlasyeah, consider
08:54bendlas,(read-string (with-out-str (pr {"A nested map of" ['symbols :keywords] 5 '(4/3 3.56) nil #{"and" :a 'set}})))
08:54clojurebot{"A nested map of" [symbols :keywords], 5 (4/3 3.56), nil #{:a set "and"}}
08:56bendlas,(ns-interns *ns*)
08:56clojurebot{}
08:56bendlaslets you walk the current namespace
08:57bendlaslooks like clojurebot has no def d vars in
08:57bendlas,*ns*
08:57clojurebot#<Namespace sandbox>
08:59bendlas,(find-ns 'clojure.string)
08:59clojurebotnil
09:00bendlas,(take 5 (ns-interns (find-ns 'clojure.core)))
09:00clojurebot([sorted-map #'clojure.core/sorted-map] [read-line #'clojure.core/read-line] [re-pattern #'clojure.core/re-pattern] [keyword? #'clojure.core/keyword?] [asm-type #'clojure.core/asm-type])
09:00bendlashaha, spamming the bot while everyone is asleep ;)
09:01Raynes&(ns-interns *ns)
09:01sexpbotjava.lang.SecurityException: You tripped the alarm! ns-interns is bad!
09:01Raynes&(ns-interns *ns*)
09:01sexpbotjava.lang.SecurityException: You tripped the alarm! ns-interns is bad!
09:02bendlas:)
09:06zvrbabendlas: that was interesting, thanks!
09:07bendlasnp
10:14Gigarobyguys can you have a look at this and tell me if the style is good ? http://pastebin.mozilla.org/898423
10:16zvrbadiagonal-up-busy? and diagonal-down-busy are almost identical.
10:16mrBlissGigaroby: some small things I would do: (= x 0) => (zero? x), (if (not (nil? x)) ..) => (if x ..), (if test nil x) => (when-not test x)
10:17zvrbawhy not abstract out the only differing part (inc/dec) into parameter and have a single function
10:17Gigarobycause
10:17Gigarobythere are
10:17Gigarobya few differences
10:18Gigarobyah
10:18zvrbasuch as?
10:18Gigarobywait
10:18Gigarobylol
10:18Gigarobyno you're righ
10:18Gigaroby*right
10:18Gigarobyi'll do it now
10:18Gigarobythanks mrBliss, zvrba
10:18zvrbaare let-bidnings in clojure just sequential var/value pairs, w/o any delimiters?
10:19mrBlisszvrba: correct
10:19GigarobymrBliss, when not will still return null ?
10:19GigarobymrBliss, meant nil
10:19mrBlissGigaroby: (when test x) returns x when test is true, otherwise nil
10:20mrBlisszvrba: same thing for Clojure's cond
10:21GigarobymrBliss, so (if x ..) if x is nill will be logically false ?
10:21zvrbamrBliss: oh :(
10:21mrBlissGigaroby: (if test x y) will do x when test is nil or false
10:22mrBlisszvrba: less parens
10:22GigarobymrBliss, thanks, very useful as useful : I love this channel lol
10:22GigarobymrBliss, as usual*
10:22mrBlissGigaroby: that's what I'm here for :-)
10:22GigarobymrBliss, my mind at 2 am of christmas is not that good lol
10:22zvrbamrBliss: less parens = more dependent on indentation / easier to get lost in long chains. like, "wait, am i now at even or odd position"?
10:23zvrba+ parens help smart editors to indent code properly
10:23mrBlisszvrba: you can delimit them with commas since they are whitespace
10:24mrBlisszvrba: but I see your point
10:24Gigarobyzvrba, I think that too many parens are difficolt to be human-readable
10:24clojurebotΜΟΛΩΝ ΛΑΒΕ
10:25zvrbaactually, I like the parens of CL. it's very uniform, and I don't have to think too much.
10:25zvrbaanyway.
10:26zvrbaGigaroby: i disagree. it's like saying too many {} make code unreadable, so you end up with python. good luck with copy/pasting pieces of code between different nesting levels.
10:26Rayneszvrba: Not many people share your love of parentheses.
10:28mrBlisszvrba: Lisp's parentheses make me feel safe. Certainly in combination with Emacs, you just know your indentation is right.
10:28Gigarobyzvrba, fair enaugh I use both java and python lol
10:28zvrbamrBliss: indeed.
10:32zvrbaRaynes: then designing a language that completely eliminated the parentheses would be the "right thing"TM. what Clojure does is just destroying uniformity. just my $.02
10:33RaynesSeems a little dramatic, but fair enough. Each to his own.
10:33dnolenzvrba: I'm writing a bit of Scheme and CL now. Uniformity is nice, but typing less parens and having structural delimiters is nice as well. let and condp are particularly tedious.
10:33dnolensorry I mean cond
10:36GigarobymrBliss, gotta a question about lazy sequences
10:36GigarobymrBliss, the values in the list are not calculated until evaluation right ?
10:36mrBlissGigaroby: sort of
10:37GigarobymrBliss, cause if you look at my last function should create a lazy sequence
10:37GigarobymrBliss, but when I do it with very big boards (suppose 20)
10:37GigarobymrBliss, take 20 secs to generate one solution
10:38GigarobymrBliss, but it does not take 20 secs to generate the list ...
10:38mrBlissI don't quite understand. But I see (lazy-seq) somewhere, which looks a bit odd
10:39GigarobymrBliss, why looks like odd ?
10:39mrBliss&(doc lazy-seq)
10:39sexpbot⟹ "Macro ([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls."
10:39mrBlissYou should put the cons in the lazy-seq
10:40mrBlissLook at the source of this function for example: http://clojuredocs.org/clojure_core/clojure.core/partition-by
10:40GigarobymrBliss, it is all enclosed into the lazy-seq
10:42mrBlissI'll try to fix your solution-list
10:42GigarobymrBliss, ty
10:43Gigaroby&(+ 1 2)
10:43sexpbot⟹ 3
10:52Rayneschouser: Can I steal the print-method method for PersistentQueues from TJoC if I explicitly give it credit in a footnote? In my book, that is. :>
10:53mrBlissGigaroby: http://pastebin.mozilla.org/898441 I didn't test it (I don't even know if it compiles correctly), but at least it gives you an idea.
10:54GigarobymrBliss, thanks a lot I'll have a look
10:57GigarobymrBliss, you think is good to do only pure functions ( except for I/O obviously ) or use mutable state for the queens object ?
10:58mrBlissGigaroby: first try it in a purely functional style, but when performance is really bad, you can go to the 'dark side' of mutability.
10:58GigarobymrBliss, well I don't need performance, I don't have to work with it xD
11:00mrBlissGigaroby: then you should certainly do everything in a functional style, except for IO (which is obviously impossible ;-)
11:20GigarobymrBliss, is there any multiline comments ?
11:20mrBlissGigaroby: no
11:20GigarobymrBliss, enclose all in "" like python will do the trick ?
11:21mrBlissGigaroby: http://groups.google.com/group/clojure/browse_thread/thread/50b5631189d524ca/8f9d9a5bab7a8a2d?lnk=gst&amp;q=multiline#8f9d9a5bab7a8a2d
11:23GigarobymrBliss, thanks
11:30sivajagThis is interesting
11:30sivajagIt's nothing like #Clojure, which is a #Lisp variant and, therefore, insane." -- lazygosu.org
11:31RaynesThere is nothing you can do to make the blind men see.
11:31mrBliss"For Developers Who Give Up Easily"
11:32sivajag:)
11:33RaynesI'm inclined to add to my book: "It's nothing like Gosu, which is a statically typed imperative language, and therefore extremely boring and repetitive."
11:33sivajagcan't believe it is going to be 2011 and we have people argue for "Having an accurate list of methods pop up after I hit '.' makes me roughly infinitely more productive, give or take."
11:33sivajaghaha raynes
11:34mrBlissI assume the name is pronounced as "Go sue", a reference to Oracle ;-)
11:35RaynesI find it difficult to be impressed with any language that feels the need to insult other languages as way to get people to use it. Gosu is doing that at every turn.
11:38mrBlissIt targets developers that are not interested in learning a new language, so why should they learn Gosu, when they won't need it for their jobs? (last negative remark from me ;-)
12:12Gigarobygood night and merry christmas guys
13:44sanderyI just upgraded to 1.3 and the repl is acting all weird, not resolving names correctly and so forth. anyone knows what's up with that?
13:52zvrbaisn't 1.3 just alpha?
15:21timmorganIn the Slime debugger, the backtrace always reports "no locals" when I toggle a frame (I tried them all)
15:21timmorganI'm using Clojure 1.2.0 -- any ideas?
15:36dsophmm how to compare records with =? (= RECORD1 RECORD2) doesnt seem to work
15:40timmorgandsop: maybe try ==
15:48timmorganno I guess not
15:51timmorganActually (= r1 r2) seems to work for me
15:53chousershould be =
15:53dsoptimmorgan: turns out that it was an error in a number in the record
15:55Clintegerlol
15:55dsop= works fine
15:56dsopClinteger: well deftest just tells you {:a 2.12 :b "c"} != {:a 2.12 :b "c"}
15:58chouserlazytest and Clojure 1.3 both have features that address that problem.
18:04Leonidassorry, I keep on forgetting... what was to name of the function to divide a sequence by a predicate? (what-is-this odd? (range 10))
18:08mrBlissLeonidas: partition-by
18:09LeonidasmrBliss: thanks
18:19LeonidasmrBliss: oh, wait, this partitions every number in its own seq, I just want 2 seqs, depending on the predicate
18:20mrBlissclojure.contrib.seq/separate does that
18:22LeonidasmrBliss: ok, maybe it was that, I can't really remember
18:28mrSpecHello! I'm playing with clojure & converting some java examples, Could you help me with http://paste.lisp.org/display/118027? How can I write this in Clojure?
18:32mrBlissmrSpec: I'm gotta go now, but have a look at http://clojuredocs.org/clojure_core/clojure.core/proxy
18:32mrSpecok, thx
19:20hippiehunteris anyone else using appengine-magic with the 1.4.0 appengine sdk?