#clojure logs

2009-03-22

00:01cmvkkhmm. using seque slows my program runs from 40 to 55 seconds at best, and causes them to never finish at all at worst.
00:03hiredmaninteresting
00:05slashus2cmvkk: You using the latest svn?
00:06cmvkkoh, probably not... but it's gotta be closer
00:06cmvkkclose*
00:06slashus2There was a recent release so that shouldn't matter.
00:06cmvkkhas seque changed a lot recently?
00:06slashus2cmvkk: There was a bug in it that was fixed a few weeks ago.
00:07cmvkkslashus2, that sounds promising
00:07cmvkkheh:
00:07cmvkkuser=> (time (dorun (take 1000000 (map + (iterate inc 0) (iterate inc 0)))))
00:07cmvkk"Elapsed time: 2104.119907 msecs"
00:07cmvkkuser=> (time (dorun (take 1000000 (map + (seque (iterate inc 0)) (seque (iterate inc 0))))))
00:07cmvkk"Elapsed time: 42286.409766 msecs"
00:08cmvkkmaybe that's a misuse...?
00:08hiredmanwell, seque is going to add overhead
00:08cmvkkyeah
00:09cmvkkwell, that's why that example is so much worse than my actual program, which was only 5/4ths off
00:09cmvkkor 1/5th off, i mean
00:50cconstantinecmvkk: this reflection thing sounds interesting...
00:50cmvkki always forget about it then it turns out to be helpful.
00:50cconstantinewhat is it?
00:51cmvkkit's what happens when the compiler doesn't know what class an object belongs to when you call its method.
00:51cmvkktry putting (set! *warn-on-reflection* true) at the top of a program
00:51cmvkkand it will tell you all the places reflection occurs in the program.
00:51cconstantineinteresting
00:53cconstantinewhat would the warning look like?
00:53cmvkkfor example: "Reflection warning, line: 33 - call to isDigit can't be resolved."
00:54cconstantinethats on a compiled .clj file?
00:54cmvkknot a precompiled clj. Just a script that's run. although reflection occurs in precompiled files also i guess
00:55cconstantineok. I"m not getting it
00:55cconstantineI'm still hunting inefficiencies in my prime generator
00:56cmvkkwell if you aren't getting any of those warnings then there probably isn't a reflection issue
00:56replacacconstantine: the warning's going to happen when the program is compiled, but all clojure scripts are compiled
00:56cconstantineok, so it should happen on evaluation of the defn, not the call to the func
00:57replacacconstantine: yeah
00:58hiredmanactually the reflection check happens at compile time (but clojure code is always compiled, AOT or JIT)
00:59hiredmanat least from what I remember of a conversation in heere it happens at compile time
00:59cconstantinehehe
00:59hiredmanbah
00:59hiredmanI really am not paying close enough attention
01:00cmvkkheh
01:00replacayeah, but generally that will appear to be the same time you're evalig the defn unless you're using AOT or paying *really* close attention
01:00replaca*evalig => evaling
01:01cconstantineok
01:01cconstantineit would make me feel better if I could invoke the warning... example?
01:01hiredmanto get rid of reflection you use type hinting
01:02cconstantineI'm not seeing it from eval of the defns through the calls to them so I'm most likely not in a reflection situation
01:02pstickneisn't there a gob of Object access floating around in compiled code? (as type hinting no raising an exception when it's incompat)
01:02hiredman,(binding [*warn-on-reflection* true] (let [a "a"] (.length a)))
01:02clojurebot1
01:02hiredmanbah
01:03cmvkkhiredman i was trying that and couldn't get it to work, heh.
01:03hiredmanI think the easiest way is passing through the function interface
01:03hiredman(defn f [a] (.lenght a)) then (f "foo")
01:03hiredmanlength
01:04cmvkk(binding [*warn-on-reflection* true] ((fn [a] (.length a)) "foo"))
01:04cconstantineok, I got it :)
01:04cmvkkcrud i forgot the comma
01:04cconstantinethanks :)
01:05pstickne,(binding [*warn-on-reflection* true] ((fn [a] (.length a)) "foo"))
01:05clojurebot3
01:05hiredmanno dice
01:05cmvkkheh
01:05cmvkkwell it works if you set! it...at least in my repl.
01:05cconstantineclojurebot might not be reporting the stderr/stdout that the warning goes to
01:05pstickneit might be being snuffed by the bot. not sure how it handles output.
01:06hiredmanyou should get stderr and stdout output from clojurebot
01:06cmvkknope. looks like 'binding' just isn't good enough for *warn-on-reflection*
01:06psticknehmm, that doesn't work here in the repl (with binding)
01:07RaynesNot working in my REPL either.
01:07hiredmanit may need set!
01:07RaynesSo we know it's no cigar. My REPL is superior to all of yours.
01:07pstickneit works with set! here
01:07psticknewhat is the type annotation syntax again?
01:08RaynesI should write a graphical front-end to the REPL.
01:08RaynesLike the one Factor uses.
01:08pstickne(it's called emacs ;-)
01:08cconstantinehehe
01:08Raynespstickne: No I mean graphical graphical. Like press buttan thing happan.
01:09replacais it really necessary for the compiler to emit 235 lines of exception backtrace just to tell me I spelled String wrong?
01:09Raynesreplaca: Sadly yes :|
01:09cmvkkit's useful
01:09replacaRaynes: I don't think it really is
01:09Raynescmvkk: It's annoying too >.>
01:09RaynesIt does it to me in Netbeans.
01:09hiredmana stack trace will save you some day
01:09replacaunless maybe you're debugging the compiler
01:10replacano, the compiler should just work
01:10Rayneshiredman: But stacktrace can be turned on. :)
01:10replacawhen my code throws an exception, that's a different thing
01:11pstickneoh, annotations work on . calls but not other stuff? :(
01:11replacabut a lot of lines of the form "clojure.lang.Compiler.analyze" aren't going to help me spell string any better!
01:11replacapstickne: you can use them ahead of the symbol on a binding form
01:11hiredmanpstickne: method calls are the places where hints are needed
01:12pstickne((fn [#^String a] (+ a 2)) "foo") :(
01:12replacapstickne: or "let"s
01:12hiredman,:(
01:12clojurebotInvalid token: :
01:12psticknevs. ((fn [#^String a] (.boogaboo a)) "foo")
01:12hiredman,(keyword "(")
01:12clojurebot:(
01:12psticknepoor clojurebot :(
01:13cconstantinedid he just frown?
01:13pstickneit looked lit it to me
01:13pstickne*like
01:13cconstantinehehe
01:14replaca,(keyword ")") ; let's keep it positive!
01:14clojurebot:)
01:14Raynes,(keyword "p")
01:14clojurebot:p
01:14clojurebotno
01:14cconstantineno?
01:15clojurebotno, I was not frowning
01:15pstickne(elisa?)
01:15replacahiredman: are you operating him behind the scenes?
01:15RaynesYes.
01:16RaynesHe is trying to trip us out.
01:16RaynesWere smarter than he previously expected.
01:16RaynesHurry quick, grab his wallet while he's in Clojurebot!
01:16cconstantineso, what's he difference between (lazy-seq (cons a b)) and (cons a (lazy-seq b)) ?
01:16replacais it like "being John Malkovitch"?
01:16hiredman,(doc lazy-seq)
01:16clojurebot"([& 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. Any closed over locals will be cleared prior to the tail call of body."
01:16cmvkkit's more like the wizard of oz.
01:17hiredmanthe body of the lazy-seq call is not evaluated until you call first on the lazy-seq
01:17replacathere was a great sppof someone did a long time ago where Richard Stallman was the wizard of oz
01:17hiredmangenerally you see (lazy-seq (cons a b)) with b being a call to the function that generates the lazy-seq
01:18psticknereplaca: "spoof"? ^^
01:18hiredmanso it's sort of like a recursive function
01:19cconstantinehiredman: so... with (lazy-seq (cons a b)) both a and b are evaulated when first is called, and (cons a (lazy-seq b)) b is only evaulated on (rest)?
01:19replacait was a usenet post mashing up Gibson and the wizard of oz
01:19hiredmancconstantine: nope, it would have to (first (rest ...))
01:20hiredmanon b
01:20replacain the end it turns out that the reason the emerald city is green is because stallman only has only grayscale but he wired it up to the green channel
01:20Rayneshttp://vmkit.llvm.org/ This is neat.
01:20hiredmanthat is the main change between pre and post lazy
01:20cconstantinereplaca: oh, I lived there awhile... it's green because everything is wet all the time and growing
01:21pstickneis there a nice way to make "case classes" or "discriminate types" in clojure? currently I am using {:kind blablah ...}
01:21replacacconstantine: cconstantine you mean in oz or in seattle?
01:21hiredman,(do (rest (cons :a (lazy-seq (prinln :foo))))) nil)
01:21clojurebotjava.lang.Exception: Unable to resolve symbol: prinln in this context
01:21cconstantinereplaca: seattle
01:22hiredman,(do (rest (cons :a (lazy-seq (println :foo))))) nil)
01:22clojurebot()
01:22replacacconstantine: this was oz
01:22cconstantinereplaca: ah
01:22hiredman,(do (first (rest (cons :a (lazy-seq (println :foo)))))) nil)
01:22clojurebot:foo
01:22cconstantinereplaca: sorry, I failed tracking
01:22replacacconstantine: yellow brick road and all :-)
01:22cconstantineright
01:22hiredman,(doc type)
01:22clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
01:22cconstantinehiredman: ok, I'm gonna need to study those two things abit
01:23hiredman,nil
01:23clojurebotDENIED
01:23hiredmanhmmm
01:23hiredman,(do nil)
01:23clojurebotnil
01:24psticknehiredman: :(
01:24cconstantinehiredman: so, either way you get a lazy sequence... right?
01:24pstickneohh. hmm.
01:25hiredmancconstantine: lazy-seq on the outisde is fully lazy, cons on the outside is less lazy
01:25cconstantinehiredman: so cons on the outside might compute an extra s-expr?
01:26hiredmanactually
01:26psticknehiredman: sneaky.
01:27hiredmanit would not matter two much, I think after the very firt element they behave the same
01:27hiredmanlazy-seq on the outside is definetly more consistent and the idomatic style
01:28psticknehiredman: now I have to go and switch conj with merge :(
01:28pstickneor at least flip the order
01:28cconstantinehiredman: on first inspection cons on the outside seems more straight forward to me
01:28hiredmancconstantine: cons on the outisde is more similar to the pre-fully-lazy style
01:28cconstantinehiredman: but I might still suffer from having a C style programming mind
01:29hiredmanlazy-seq is a lazy layer that wraps your infinite list and makes it lazy
01:30pstickneokay, so now suppose I have a bunch of these hash-maps objects floating about. what is a good way to indicate that function x operates on that 'type'?
01:30pstickne(or group)
01:30hiredman(defn F [n] (cons n (F (inc n))))
01:30cconstantinehiredman: ok
01:31hiredmanF would create an infinte series of cons sells, but non-lazy
01:31cconstantinehiredman: that never returns on (f 1) right?
01:31hiredman(defn F [n] (lazy-seq (cons n (F (inc n)))))
01:31hiredmancconstantine: yeah it goes foreaver
01:31hiredmanthe new F is now lazy
01:32hiredmanbut not the best example I think
01:32pstickneI think that makes sense.
01:32pstickneIt's similar to using delay/force.
01:32cconstantineok... I can play with putting printlns in and doing first/rest combos on it
01:33psticknelazy sequences are awesome for backtracking parsers :p
01:34hiredmanthe problem there is the (inc n) would happen when you call rest (I think) instead of ideally (first (rest ...))
01:35hiredmanor (seq (rest ...)) for that matter
01:35cconstantineoooo delay/force looks interesting
01:37hiredman~def delay
01:38hiredmaninteresting
01:38hiredmanI think lazy-seq uses the :once metadata too
01:39cconstantinelazy-seq claims to only evaluate (rest ...) (or maybe (first (rest ...)) ) once
01:39hiredmanit evals first once
01:39hiredmanrest never evals anything
01:40hiredmanunless you do it less then right
01:40hiredman,(doc rest)
01:40clojurebot"([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."
01:40hiredmanhuh
01:40hiredman,(doc next)
01:40clojurebot"([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."
01:40hiredmanhmmmm
01:41hiredman,(class (rest (range 100)))
01:41clojurebotclojure.lang.Range
01:41hiredman,(class (next (range 100)))
01:41cconstantinehahahah! if I leave the lazy-seq prime around it's super-fast the next time I used it :)
01:41clojurebotclojure.lang.Range
01:41hiredmancconstantine: yeah, well, it's cached
01:41cconstantinew00t :)
01:42hiredman,(class (next (iterate inc 0)))
01:42clojurebotclojure.lang.Cons
01:42cconstantineand that cache.... could it ever cause java to run out of memory?
01:42hiredman,(class (rest (iterate inc 0)))
01:42clojurebotclojure.lang.LazySeq
01:42hiredmanhmmmm
01:42cconstantinelike if I were to pre-cache primes on compile
01:42hiredmanthe docstring for rest apears to be off
01:42hiredmancconstantine: well, of course the cache is in memory
01:43hiredmanso a large cache would use all the memory
01:43cconstantinehiredman: well.. normally caches have a fixed size and clean themselfs up when memory is needed for other things
01:44cconstantineor at the very least have a fixed size
01:45hiredmanthat is a behaviour of somethings called caches, but not a property needed to be a cache
01:45hiredmanin this case it means computed once, and held on to as long as a reference to the result exists
01:47cconstantinehiredman: ok... so if I keep it around as a var I could 'leak' memory
01:48hiredmannot leak
01:48hiredmanit's there, you have a reference to it, you can get to it
01:48cconstantineleak in the sense that it's memory thats set aside for something. If that thing is never used....
01:49cconstantineyou're right... not leaked in the strict sense
01:49hiredmanif the seq is never used then, being a lazy-seq, it be there
01:50hiredmaner
01:50hiredmanit won't
01:50hiredmanbut if you are using a lazy infinite seq, it is best not to hang on to the head of the seq
01:50cconstantineI'm thinking: I could pre-cache a bunch of primes at compile-time and make the prime generator seem really fast at runtime
01:51hiredmancconstantine: type out a bunch of primes in a list then concat that with a lazy-seq of primes
01:52cconstantineyeah
01:52hiredman,(concant '(1 2 3 4) (take 5 (iterate inc 5)))
01:52clojurebotjava.lang.Exception: Unable to resolve symbol: concant in this context
01:52hiredman,(concat '(1 2 3 4) (take 5 (iterate inc 5)))
01:52clojurebot(1 2 3 4 5 6 7 8 9)
01:53hiredmanprime the pump so to speak
01:53cconstantinehehe, yeah :)
01:55cconstantinewould it be cheating to say... precompute the solution to http://projecteuler.net/index.php?section=problems&id=3 at compile time and claim it's super-fast because it only has to do a cache lookup at runtime?
01:56RaynesWhy do people have to complain about parentheses so much?
01:56RaynesIt's annoying.
01:56RaynesNo worse than 10 thousand curly braces in a 3 thousand line file. :|
01:57cconstantineRaynes: I think it's fair to say there are no more parens than (+ parens curlies) in C
01:57zakwilsonThey don't know what it is they're looking at.
01:57Raynescconstantine: Huh?
01:57zakwilsonExplaining that *everything* is an expression that has a value might help.
01:58cconstantineRaynes: if you were to count all the parentheses and curly braces in a C program, and count the parentheses in a similar lisp program you would get roughly the same number
01:59RaynesConsidering the lines you would save writing the program in Clojure, that might be true.
02:01Raynes"I was flirting a bit with the ??? and looking at Clojure. While I am not that impressed (LFE is better :-)) there was some interesting stuff in the Rationale:..."
02:01RaynesI can't figure out what the ??? is :(
02:02replacaLFE == Lisp Flavored Erlang here?
02:03RaynesYes.
02:03hiredmanno
02:03RaynesWas from the Erlang mailing list.
02:03RaynesI stalk them sometimes.
02:03hiredmanmostly it has been used to mean left-fold-enumerator
02:04hiredmanRaynes is relatively new and may have missed that
02:04hiredmanat one point rhickey was looking at LFEs for safe resource consumption in clojure
02:05replacaahh
02:05hiredmanbut I think he decided that is was to complex to expect people to use
02:05hiredmanscopes are the future, but they are not in trunk yet
02:05hiredman~scopes
02:05clojurebotGabh mo leithsc�al?
02:06hiredman~scope
02:06clojurebotscope is at http://paste.lisp.org/display/73838
02:06Rayneshiredman: Where is your "Thank you rich!" in my group post? I don't know your real name.
02:08hiredmanRaynes: /whois hiredman
02:08RaynesOf you suck.
02:08RaynesOh*
02:09hiredman...
02:09cconstantineI really don't understand that scope thing
02:10hiredmancconstantine: the idea is you can register things to be run when you exit the dynamic scope of the (scope ...)
02:11pstickne(so it's stack-based like 'with' or 'using'?)
02:11cconstantineah, I see
02:11hiredmanyou can register things to run if you exit with no exceptions thrown, or with exceptions thrown
02:11RaynesOh that's cool.
02:11hiredmanor regardless
02:11psticknehiredman: isn't it just a special-form of try-catch? or can you bind events later?
02:11hiredmanpstickne: later...?
02:11pstickne(which would be more akin to obj-c autorelease-pools)
02:12psticknesure :)
02:12hiredmanso you could make a function open-file which would attach close file to the enclosing scope, and throw an error if not used in a file
02:12hiredmaner
02:12hiredmannot used in a scope
02:13psticknewhy not just (open-file [do stuff here]) ?
02:13hiredmanpstickne: scope is more general
02:13pstickneruby has that idiom: open("foo") {|f| use_f_here} # f closed here
02:14hiredmanscope would allow you to put resource clean up inside the function that creates the resource
02:14psticknelike open-file (macro)
02:14pstickneor fn-caller
02:14hiredmanerm
02:14hiredmanI do not believe so
02:15pstickneimagine: (open-resource function-to-call)
02:15hiredmanand what does that do?
02:15hiredmanwhat does it return?
02:15psticknethen open-resource opens and closes the resource (this is a non-dynamic stack-based scope)
02:15psticknehiredman: what function-to-call does
02:16hiredmanhmmm
02:16hiredmanscope still seems nice
02:16hiredmannicer
02:16pstickneneedless to say, it's not good for resources opened here and used there :p
02:17slashus2The duck stream reader from contrib is really nice.
02:17pstickneslashus2: what does it do?
02:17slashus2very useful
02:18hiredmanit helps with dealing with all of javas various IO classes
02:18psticknehiredman: if you had a more dynamic scope, maybe ... (scope .... (attach cleanup) ...);
02:18pstickneoh, not Java IO :(
02:18hiredmanpstickne: uh, that is exactly what scope does
02:18psticknethen like obj-c autorelease pools :p
02:19hiredman(defn open-file [f] ... (when-scope :exits (.close f))) (scope do stuff (open-file "foo") do more stuff)
02:20replacaQ: How do I hint a "char[]"? #^Character[] doesn't seem to do what I want.
02:20hiredman,(into-array Character/TYPE [\a \b])
02:20clojurebot#<char[] [C@965654>
02:20slashus2pstickne: reader from duck-streams: Attempts to coerce its argument into an open java.io.BufferedReader. Argument may be an instance of Reader, BufferedReader, InputStream, File, URI, URL, or String.
02:21hiredman,(class (into-array Character/TYPE [\a \b]))
02:21clojurebot[C
02:21ChairosI understand clojure-contrib has a sql library? Do you have to write your own sql as strings, or can you write sql in clojure, and thus manipulate the query structure easily with code?
02:21replacahiredman: are you saying I've got to convert it and then it will know?
02:21hiredmanChairos: you what clojureql, which is not in contrib
02:22hiredman~clojureql
02:22clojurebotclojureql is a quite impressive piece of work
02:22pstickneslashus2: crazy :)
02:22hiredmanbah
02:22hiredman~clojureql
02:22clojurebotclojureql is http://github.com/Lau-of-DK/clojureql/tree/master
02:22replacahiredman: but if I'm in this routine, it should already be a char[]
02:22hiredmanreplaca: I am saying nothing
02:22replacaoh, ok
02:22hiredmanjust doodling on the wall
02:23Chairosaha
02:23Chairosmy googling didn't find that
02:23Chairosexcellent
02:23hiredmanreplaca: I would ask, why type hint it as Character[] if it is a char[]
02:23hiredmanI think there was a thread about type hinting arrays on the group
02:24replacacause the compolier pukes all over #^char or #^char[]
02:24hiredmantry [C
02:24replacaI asked the same thing of myself :-)
02:24replacaI did, the compiler really hates that!
02:24slashus2replaca: does #^chars work?
02:24replacabut maybe if I put it in a map
02:25replacaslashus2: 1 sec, let me try
02:26replacaslashus2 wins the prize! I never would have guessed that. :-)
02:26replacaslashus2: thanks!
02:26slashus2yey
02:26slashus2replaca: It works with #^floats #^strings I think too among others.
02:27slashus2I don't know about strings :-|
02:27pstickne(type #^{:type :x} (struct-map x :foo :bar)) ;-(
02:27replacaslashus2: hmm, doesn't seem right somehow.
02:27replaca#^String
02:27psticknethat returns a PersistentStructMap -- why?
02:27replacaI've got that all over
02:27hiredman,(type #^{:type :x} (struct-map x :foo :bar))
02:27clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
02:28hiredman,(type #^{:type :x} {:a :b})
02:28clojurebot:x
02:28pstickne,(type #^{:type :baz} (struct-map (defstruct x :foo) :foo :bar))
02:28clojurebotDENIED
02:28pstickne:(
02:29slashus2replaca: from http://clojure.org/java_interop -> Type hints for primitive arrays - #^ints, #^floats, #^longs, #^doubles
02:30pstickne,(type #^{:type :baz} (struct-map (create-struct :foo) :foo :bar))
02:30clojurebotclojure.lang.PersistentStructMap
02:30hiredman,(let [a (struct-map (create-struct :foo) :foo :bar)] (type #^{:type :x} a))
02:30clojurebotclojure.lang.PersistentStructMap
02:31hiredman,(let [a (struct-map (create-struct :foo) :foo :bar)] (type (with-meta a {:type :x}))
02:31clojurebotEOF while reading
02:31hiredman,(let [a (struct-map (create-struct :foo) :foo :bar)] (type (with-meta a {:type :x})))
02:31clojurebot:x
02:31pstickneI was kind of hoping create/def struct would attach some semblance of a type by default too :(
02:31hiredman*shrug*
02:31pstickne(heck, I don't even know why I am using them :-)
02:31pstickne"it's all just maps" I suppose
02:32replacaslashus2: wow, that was two lines down off the bottom of my browser (since I was looking at the type tag section just above.) :-)
02:32hiredman,(meta #^{:type :x} (struct-map x :foo :bar))
02:32clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
02:33hiredman,(meta #^{:type :x} (struct-map (create-struct :foo) :foo :bar))
02:33clojurebotnil
02:33hiredman,(meta (with-meta (struct-map (create-struct :foo) :foo :bar) {:type :x}))
02:33clojurebot{:type :x}
02:33hiredman*shrug*
02:33nascent16i'm bit of a lisp newbie, but let's say I want to have a database api that doesn't define its operating functions until we're told that we're acting on a particular api, so like (db/use "mydb.db" (put key value) (println (get key))) would print the value i stored
02:34psticknehiredman: is using meta for this purpose "good"?
02:35nascent16i think i need to use a macro for "db/use" since the db/get and db/put functions wouldn't be defined at parse time
02:35hiredmanpstickne: what purpose?
02:36hiredmannascent16: / is used for namespaces in clojure
02:37hiredmanbut sure
02:37hiredmanyou can do that
02:37nascent16hiredman: i know, i'm putting all these in a namespace
02:37nascent16ok
02:37hiredmanit;s kind of silly though
02:37nascent16yeah?
02:37psticknehiredman: tell different object-types apart :p
02:38hiredmanpstickne: that is the whole reason the type function exists
02:38hiredmanso it can be used this way
02:38hiredmannascent16: get and put may as well be functions
02:38pstickneI need to understand the entire object system in clojure better :(
02:39hiredmanpstickne: this is my clojure object system: ick, no
02:39pstickneIs there a multi-method or something else dispatched on type to add 'custom' printers?
02:39psticknehiredman: :(
02:39hiredmanyeah
02:39nascent16hiredman: that's what i have right now, db/get and db/put are functions, but they aren't defined until db/use is called so that they can be bound to a database object with let
02:39hiredman,(doc print-method)
02:39clojurebot"; "
02:39hiredman~def print-method
02:40slashus2no doc :-(
02:40replacaAh, a night spent with type tags just double the speed of the pretty printer. Yay!
02:40hiredmanI think it's print-method
02:40pstickneyeah :)
02:40psticknebut I have no idea what writer is supposed to be :-/
02:41replacaI think it's supposed to be any java.io.Writer
02:41replacalike *out*
02:42hiredman,(class *out*)
02:42clojurebotjava.io.StringWriter
02:42replacathat's because clojurebot has it bound
02:42hiredmanat the repl it is a java.io.OutputStreamWriter
02:42nascent16so what i have now is (defmacro use ([database & expressions] `(let [db (<open database stuff>)] (defn put ....) (defn get....) (do expressions))))
02:42nascent16but that doesn't work
02:43replacaand in Slime it's a proxy
02:43nascent16Unable to resolve symbol: db in this context
02:43hiredmanugh
02:43hiredmandon't use defn
02:44hiredmanyou you have a set or parens you would only need you where writing a multimethod
02:44hiredmanor multifn I should say
02:44pstickneyay! my first method dispatch!
02:45hiredmannascent16: you have picked a bad first macro
02:45psticknehiredman: so you're not a fan of the clojure of the hierarchy and all?
02:45nascent16haha
02:46hiredmanpstickne: I haven't used it
02:46hiredmanit annoys me to see trying to implememnt an oop system on top of clojure
02:47psticknebarring some performance reasons and possibly a place to collect some documentation, is there a reason for structures? (e.g. am I missing something crucial?)
02:47hiredmannascent16: you are going to need to do stuff like symbol capturing and what not
02:47psticknehiredman: multi-dispatch is OO by default :p
02:47replacapstickne: that's basically it
02:47slashus2polymorphism
02:47hiredmanpstickne: uh clojure's multi-dsispatch can dispatch on any function
02:48hiredmanup to and including the time of day
02:48slashus2polymorphism is just a subset of features within the OO paradigm
02:48slashus2just one*
02:48psticknehiredman: so you'd say it offers polymorphic behavior capabilities based upon abstract data types? ;-)
02:48hiredmanslashus2: OO is a subset of polymorphism
02:48replacaa nice thing in clojure is that you can pick nd choose the OO features you want
02:49psticknenot if you're dealing with Java :)
02:49slashus2hiredman: You know what I meant. Just said it backward.
02:49pstickne(which is the white elephant)
02:49nascent16hiredman: interesting. meaning, i have no idea what that means. off to google for a bit :)
02:50hiredmanpstickne: we aren't dealing with java, we are dealing with clojure's multimethods
02:57pstickneis all meta information forever kept with an object?
02:57hiredman~def c.l.IMeta
02:59hiredman,(let [x {} y (with-meta x {})] (identical? x y))
02:59clojurebotfalse
02:59hiredmanI think adding metadata makes a new object, so removing would too
03:00hiredman,(let [x {} y (with-meta x {})] (= x y))
03:00clojurebottrue
03:00slashus2,(let [x {} y (with-meta x {}) z y] (identical? y z))
03:00clojurebottrue
03:01hiredmanwell
03:01hiredmanduh
03:01slashus2I thought I was doing something else there.
03:04hiredmanminding the shop without Chouser makes me nervous, he should have corrected me about something by now
03:15replacatime for sleep. G'night all!
03:22hiredman,(int \?)
03:22clojurebot601
03:25cmvkkthat's a pretty high number for a character
03:26hiredman,(char 345)
03:26clojurebot\?
03:26hiredman,(char 1342)
03:26clojurebot\?
03:26cmvkkis it unicode?
03:27cmvkk,(char 0xAC00)
03:27clojurebot\?
03:27hiredmanjava is unicode, so is clojure
03:27cmvkkhmm, so it is.
03:27hiredmanwow
03:27hiredmanI didn't know unicode had korean as vowel consonant pairs
03:27hiredmaner, consonant vowel
03:27p_lhiredman: try some of the combining characters :D
03:27cmvkkit has all the syllables. it would be really hard to write otherwise...
03:27hiredmanI guess it would have to
03:27cmvkk,(char 0xAC01)
03:27clojurebot\?
03:28hiredmangak
03:28hiredmangahk?
03:28cmvkkand the best part is, all the vowels/consonants are at deliberate intervals. so if you know the constituent parts of the syllable, you can figure out the code by math.\
03:28hiredmangahg
03:28hiredmaninteresting
03:28cmvkk,(char (+ 0xAC00 0x1B))
03:28clojurebot\?
03:29cmvkk,(char (+ 0xAC00 0x1C))
03:29clojurebot\?
03:29hiredmancute
03:31hiredmanI guess someone had their thinking cap on
03:32cmvkkit takes up more space that way i guess. various combinations don't actually exist, so their codes just have blank spaces or whatever
03:36nascent16Ok, I learned all about symbol capture, but now I have new problems :)
03:37nascent16let's say i want to use a java class in a macro ie: (import '(tokyocabinet HDB)) (defmacro open ([file] (let [db (HDB.)] .....)))
03:37nascent16waith
03:37nascent16that's not right
03:38nascent16(import '(tokyocabinet HDB)) (defmacro open ([file] `(let [db (~HDB.)] .....)))
03:38nascent16that complains that the class cannot be found
03:40nascent16but HDB is defined, I can print it out
03:40nascent16it doesn't let me construct a new one though
03:40hiredman(~HDB.)
03:40cmvkknot sure why you need a ~ there
03:40hiredmanthat is not right
03:40nascent16ok
03:41nascent16don't i need the ~ to refer to a symbol that was defined outside of my macro?
03:41hiredmanalso you are putting extra parens around your macro body
03:41hiredmanwell
03:41cmvkkhiredman it might be multiple arity
03:41hiredmanaround the arglist and body
03:41hiredmancmvkk: care to make a wager?
03:41cmvkkwell i don't know...that's how it would look
03:41hiredmanyes, that is why he doesn't get an error
03:42hiredmanbut it is incorrect, and should corrected before too long
03:42slashus2db#
03:43nascent16yeah, you also need to do db#, sorry
03:43nascent16but that doesn't solve the ClassNotFound thing with HDB
03:43cmvkkdid you try it without the ~
03:43nascent16yeah, same error... wasn't expecting that
03:43cmvkkhmm
03:43RaynesI have a Bologna and Banana pepper sandwich with yellow mustard.
03:43nascent16oh wait
03:44nascent16nope
03:44nascent16i'm an idiot
03:44hiredmannascent16: does (HDB.) work on the repl?
03:44nascent16it does outside of a macro
03:44hiredmannascent16: pastebin your whole macro
03:44hiredmanlisppaste8: url?
03:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
03:44nascent16sweet, it works without the "~"
03:45hiredmannascent16: you need to remove some parens
03:45nascent16i did
03:45hiredmanor you should
03:45hiredmangood
03:45p_loo, there's a tokyocabinet binding for java? :)
03:46hiredmanwhen writing macros I often find it is easier to write a function that returns a data structure first
03:46hiredmanand then when the data structure is the corrent form, switch to a macro
03:47cmvkkhiredman isn't it easier to just use macroexpand
03:47cmvkkespecially when you expect your input to not be evaluated
03:47hiredmancmvkk: sometimes
03:47nascent16p_l: there is, it's part of the tokyocabinet project
03:47hiredmandepends on the situation
03:47nascent16http://pastebin.com/mba6a8a0
03:47hiredmanI often end up with helper functions
03:47hiredman(for the macor)
03:47nascent16now it's giving me a " Can't refer to qualified var that doesn't exist"
03:48Raynesnascent16: Don't use pastebin.com use http://paste.lisp.org/new/clojure (there is a reason ;) )
03:49cmvkkyou probably don't want to import your class inside the expander code
03:49hiredmannascent16: lets see the whole exception
03:49lisppaste8nascent16 pasted "tokyo" at http://paste.lisp.org/display/77412
03:50nascent16hiredman: on the repl, i only get one line: java.lang.Exception: Can't refer to qualified var that doesn't exist (NO_SOURCE_FILE:2)
03:51slashus2nascent16: put ~'[key value] and ~'[key]
03:51nascent16Raynes: that pastebin thing is pretty cool
03:51nascent16slashus2: ah, that makes sense
03:51hiredman~google tokyocabinet
03:51clojurebotFirst, out of 12800 results is:
03:51clojurebot??????????? Tokyo Cabinet
03:51clojurebothttp://tokyocabinet.sourceforge.net/
03:53nascent16for those of us who don't know japanese: tokyocabinet.sourceforge.net/spex-en.html
03:53hiredmanand you are closing the database
03:53hiredmanoh
03:54hiredmando ~@body
03:54hiredmanugh
03:54hiredmandon't use defn in there
03:54nascent16ok
03:54nascent16what should i use?
03:54hiredman(let [get (fn ...)])
03:54hiredmanlike that
03:55hiredmanyou will need to ~'get
03:56hiredmannascent16: I think you would be better off just writing a wrapper around with-open
03:56nascent16with-open eh
03:56hiredmanthat opens the database and binds *db* to a hdb instance
03:56slashus2This is probably a terrible example (defmacro add-them [] `(defn addum ~'[one two] ~'(+ one two)))
03:56hiredmanand then get and put just normal functions that read from *db*
03:58nascent16hmm, that doesn't seem cleaner to me... what if i have multiple threads reading from multiple databases? they would step on each other, wouldn't they?
03:59hiredmanuh
03:59hiredmanno
03:59hiredmanwell, that depends on the library
04:00hiredmanthe way you are writting it would not help with multithreading if the java lib you are using doesn't handle multithreading
04:00nascent16i'm just talking about the clojure side
04:00hiredman~def with-open
04:03nascent16ok, i think with-open looks like a solid starting point
04:03nascent16thanks
04:04lisppaste8hiredman annotated #77412 "using with-open" at http://paste.lisp.org/display/77412#1
04:05hiredmansomething like that, much simpler
04:05slashus2hiredman: Is this the correct way to do this, or is there a better way? (defmacro add-them [third] `(defn addum [~'one ~'two] (+ ~'one ~'two ~third))) I am just playing around.
04:05hiredmanuh
04:05slashus2Just doing ~'[one two] seems to work at the last
04:06hiredmanthat is sick
04:07hiredman(defmacro add-them [third] `(defn addnum [one# two#] (+ one# two# ~third)))
04:07hiredmancapturing symbols with ~' is to avoided
04:07hiredmanuse gensyms
04:07hiredman,`one#
04:07clojurebotone__1989__auto__
04:07slashus2I was looking at some code in compojure
04:08nascent16hiredman: that does look better... quite nifty actually
04:08hiredmanI must warn you, I have no idea if it works
04:09slashus2hiredman: The code I was looking at in compojure changed from using ~' to using autogensyms
04:09hiredmangood
04:09nascent16haha, well i can find that out pretty quickly
04:13hiredmancome to think of it, you may runto issues with clojure's use macro
04:13hiredman,(doc use)
04:13clojurebot"([& args]); Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exclude, :only, and :rename are the same as those documented for clojure.core/refer."
04:13slashus2hiredman: http://tinyurl.com/cpqoon <-- at the bottom of the stable version of compojure defservice
04:13slashus2I was looking at that as an example. That is why I wrote my code the way I did, but I see that it is changed in the development branch.
04:14hiredmanwell, there are times when you want to capturing a symbol like what I just did
04:25nascent16hiredman: you did ~body instead of ~@body... any particular reason?
04:29lisppaste8nascent16 annotated #77412 "with-open version that works" at http://paste.lisp.org/display/77412#2
04:29nascent16the only changes i really needed were to use ~@body and to use backtick instead of quote for getting at *db*
04:49hiredmannascent16: not paying close enough attention
07:33melwinHello...? Sorry, may I ask - what's the clojuromatic way of defining function-local function definitions? Is it with let and fn? As in reduced example: (defn x [] (let [fun (fn [] 1)] (fun)))
07:37Carkeright that's how it's done
07:38melwinCool, thanks a lot.
07:38teLau_of_DK: We need to talk
07:38teLau_of_DK: you registered Clabango! /me stabs you
07:38teLau_of_DK: I was totally going to grab that
07:38Lau_of_DKClabango.com, or Github?
07:39teClabango.com
07:39teboth gave me a laugh by the way
07:39te:)
07:39Lau_of_DKYea me too - Its pjstadig you should be angry with though :)
07:39teThat bastard
07:39Lau_of_DK~ it was feeling all ready to buy it, when suddenly...
07:39teClabango is such a great name
07:39clojurebotCLABANGO!
07:40teIt's light-hearted, memorable, it's a verb
07:41teit's like twitter, only with less sexual connotations
07:41teim sorry but from the first time i heard "twitter", i thought of "diddling"
07:41teit's a crappy name IMO
09:58hjlee,(doc doc)
09:58clojurebot"([name]); Prints documentation for a var or special form given its name"
11:11digash`Chouser_: hi, i am the guy in the front row.
11:16Chouser_digash`: hi
11:44Mecis it faster during runtime to use macros over functions?
11:46Chouser_probably, but you're second-guessing hotspot
11:47Chouser_don't use a macro for only that reason without profiling and demonstrating it actually helps.
11:47Chouser_and if you do find it helps, consider definline
11:47Mecok
11:57Mecwill a :while break an entire for expression or just the nearest loop it's placed to
11:58Chouser_nearest (and sub) loop
11:58Mecexcelent
12:01digash`,(def *bla* (ref []))
12:01clojurebotDENIED
12:01digash`,`[~ @*bla*]
12:01clojurebotjava.lang.Exception: Unable to resolve symbol: *bla* in this context
12:02Chouser_,(let [x (atom 5)] `(do ~@x))
12:02clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Atom
12:02Chouser_,(let [x (atom 5)] `(do ~ @x))
12:02clojurebot(do 5)
12:02digash`Chouser_: cool
12:02Chouser_brilliant -- hadn't occurred to me.
12:03thickey_i like that clojurebot is helping during the presentation!
12:06Mechmm a macro expanding to (when true (if true ...)) doesnt seem right
12:07digash`,(let [x (atom 5)] `(do ~,@x))
12:07clojurebot(do 5)
12:07digash`:)
12:07Chouser_heh
12:08Chouser_Mec: which macro?
12:08Mec,(macroexpand '(for [a (range 5)] a))
12:08clojurebot(let* [iter__4470__auto__ (clojure.core/fn iter__2021 [s__2022] (clojure.core/lazy-seq (clojure.core/loop [s__2022 s__2022] (clojure.core/when-first [a s__2022] (clojure.core/cons a (iter__2021 (clojure.core/rest s__2022)))))))] (iter__4470__auto__ (range 5)))
12:08Chouser_Mec: or perhaps more importantly, which version of ... yeah.
12:08Meclooks like the newer version doesnt
12:09Mecbleh i want the newer version but i'm really not looking forward to realearning lazy sequences
12:12Chouser_,(get '{a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8} 'a)
12:12clojurebot1
12:12Chouser_,(get '{a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9} 'a)
12:12clojurebot9
12:13Chouser_don't rely on that, by the way, not that I know how you could.
12:15Mecwell that's bizare, i thought the last occurances was always taken
12:16Chouser_,(class '{a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8})
12:16clojurebotclojure.lang.PersistentArrayMap
12:16Chouser_,(class '{a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9})
12:16clojurebotclojure.lang.PersistentArrayMap
12:16Chouser_hm
12:17Chouser_anyway, arraymaps act slightly differently than hashmaps, but not in any way that you should rely on.
12:19Mechuh, i thought {} was for hashmaps, hadnt even heard of arraymaps till now
12:21mgarrissgetting this error (using slime mode in emacs for clojure): Exception in thread "Swank REPL Thread" java.lang.VerifyError: Cannot inherit from final class
12:25Mecwhich clojure page is most up to date? lazy lazier lazier1
12:26thickey_Mec: lazy
12:26Mecthanks
12:26StartsWithKshould every future deref go in try block? http://paste.pocoo.org/show/109046/ so it prevents cancellation exceptions
12:30Chouser_StartsWithK: like agent actions?
12:32fandahello all!
12:32fandajust a small suggestion: genclass.clj in src\clj\clojure\
12:32fandawould be nicer if renamed to core_genclass.clj since it is loaded by core and to maintain consistency with print and proxy
12:32StartsWithKChouser: yes, agent does .cancle on future before its done, and @f then fails, this will not fail if i do (.cancle f false)
12:32StartsWithKel*
12:34fandaotherwise all other libraries have correctly non-core names :-)
12:35StartsWithKwhat im trying to do is, i create a future, then you can deref it or not, but if you don't and i create another future, i would like to cancel the one no one needed and replace it with a new one
12:35Chouser_fanda: you're just talking about the file name?
12:36fandayes, just the file name
12:36fandanothing big :-)
12:36fandafor the sake of symmetry, i guess
12:47digash`,`()
12:59SethTisuehi. does the clojure REPL have something like Common Lisp's *, **, *** for accessing the results of the forms you just typed?
13:00StartsWithK*1, *2, *3
13:00SethTisuegreat, it works, thanks
13:00Mecwhat would commonlisp make of (* * *)
13:01SethTisuethat would work since it's a Lisp-2
13:01SethTisueI'm at the Clojure tutorial Rich is giving at the International Lisp Conference. trying stuff out
13:01Mecwhat if the last result was a function tho would it call multiply or the result
13:02teSethTisue: cool
13:02SethTisueit would call multiply. in CL the function namespace is separate from the namespace for variables
13:03teSethTisue: what is CL?
13:03Meccommonlisp
13:03p_lte: Common Lisp
13:03pstickneComplicated Lisp
13:03pstickne:)
13:03Meclol
13:03telol I kid
13:03teWhat is this CL everyone keeps going on about?
13:04Meci dunno that id care for a lisp-2
13:04teCoronal Lobotomy?
13:04p_lte: Your speech doesn't not compute, please specify continuation: 1) troll 2) genuine question
13:04te1
13:05Mecdoesnt not?
13:05tedoes not*
13:05SethTisueI was hoping I could type a form into the repl and then ask to see the disassembled bytecode the compiler generated
13:06p_lMec: computation failure ;-)
13:06SethTisueRich told me I need to use the AOT compiler and then use javap to get the disassembly
13:06SethTisuebefore I write a little script that does that
13:06SethTisuedoes anyone have one lying around?
13:06teSethTisue: You're motivated
13:08teSethTisue: You scare me
13:10cconstantineI'm getting a 'java.lang.OutOfMemoryError: GC overhead limit exceeded' from my clojure program.... does that mean I'm doing things horribly wrong?
13:10Mecare you keeping around the head of an infinite sequence while processing it?
13:11Mec,`()
13:11cconstantineMec: Nope
13:11SethTisuehaha, someone just reported the r1337 bug to Rich about 10 minutes ago
13:11SethTisue1337 is a good bug number
13:11Meccconstantine: thats usually what im guilty of :D
13:11SethTisueI mean revision number
13:11cmvkkman i noticed we were coming up on that
13:12cconstantineMec: It's just a lot of fast-running lazy sequences
13:12cmvkkare you actually at this thing, SethTisue? like in a room IRCing it up with us over wi-fi?
13:13SethTisuey
13:13SethTisuelunch break
13:18cconstantineIs it possible that I'm allocating faster than the GC can clean it up?
13:19cmvkkit doesn't seem likely
13:20cmvkkthe GC will run when necessary, stopping the program to do so.
13:21cconstantineok
13:22cmvkkon the other hand:
13:22cmvkk"
13:22cmvkkThe parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown."
13:22cmvkkwhat exactly is your program doing?
13:23cconstantineremember my counter thing from yesterday?
13:23cmvkkkind of
13:24lisppaste8cconstantine pasted "Prime seive" at http://paste.lisp.org/display/77421
13:24cconstantineit's a lazy sequence like range
13:25cconstantineI've created a lazy sequence of primes, and each prime found means a new counter is created and put in the seive
13:26cmvkkso you're allocating an object for every prime
13:26cconstantineyeah, every prime is a cons
13:28SethTisuesound like someone's working on Project Euler
13:30cmvkkeach prime is a lazy-seq, and maybe you're holding onto the head of that from the hash map? i can't tell
13:30cconstantineSethTisue: hehe, yeah. using it to learn clojure
13:31cconstantinecmvkk: could this be a (lazy-seq (cons ...)) vs. (cons (lazy-seq ...)) thing?
13:32cmvkki don't think so...a variation there wouldn't cause an out of memory error
13:32cmvkkor at least i can't think of why it would
13:32psticknein a defmethod, is there a way to "match any"?
13:33Chouser_:default
13:33psticknethanks
13:35cmvkkare you replacing every seive in your hash map, though?
13:35cconstantinecmvkk: I should be
13:35cmvkkif not, then the hash map is holding on to the heads of all those lazy-seqs.
13:36cconstantinethe hash-map is just a set of counters for every previous known prime, the key being the first number in the seq
13:36cmvkkright. so as you go along, you're checking every counter in the map to see if it contains your current prime candidate?
13:37cconstantinecmvkk: just the lowest
13:37cmvkkjust the lowest counter? does that work?
13:38cconstantineit should?
13:38cmvkki'll take your word for it, i don't know anything about this algorithm
13:39cmvkkbut you should look into making sure you aren't expanding those counters while holding the head.
13:39cconstantineI've experimented with remembering the head of the primes lazy-seq and I can watch the java process eat progressively more memory. I"m not seeing what I pasted eat more memory
13:39pstickneis there a way to bind the value of a matcher (e.g. :default) to a variable?
13:40cmvkkcconstantine: and the fact that it's not an 'out of heap space' error, but a 'GC overhead limit' error seems suspicious
13:40thickey_ilc: should he not be using map as a symbol there?
13:40cconstantinecmvkk: yeah, if it was just a "no more memory" kinda thing that would be one thing
13:42Chouser_thickey_: nor 'keys' nor 'vals', I would think
13:42thickey_Chouser_: thanks
13:42pstickneoh, dear :(
13:43psticknedefault doesn't work in compound matcher?
13:43Chouser_pstickne: right. known issue
13:43pstickne:-/
13:43psticknebest work-arounds?
13:44cconstantinecmvkk: This is a standard seive, execpt that instead of marking/removing non-primes in an array of numbers, I'm keeping a counter around for each prime.
13:44psticknewow. *sniff*
13:44Chouser_pstickne: http://groups.google.com/group/clojure/browse_thread/thread/9793367d342fd2ce
13:45eeee includes the original list, too?
13:45Chouser_eee: ilc slides?
13:45pnkfelixilc: d not bound in 3rd ex?
13:46eeeyeah, slides
13:46thickey_pnkfelix: correct
13:46eeeseems counter intuitive to english . . .but useful
13:46pstickne*sigh*
13:46psticknethis makes multi-dispatch almost worthless to me :(
13:47eeewould have thought it would be a litst with a b c d
13:49scgilardihttp://home.pipeline.com/~hbaker1/ObjectIdentity.html
13:49SethTisuebtw the ILC tutorial slides are at http://clojure.googlegroups.com/web/tutorial.pdf
13:49slashus2pstickne: Use derive
13:49slashus2from Programming Clojure: (derive ::Savings ::Account) (derive ::Checking ::Account)
13:51pstickneslashus2: I don't think it makes sense here. I have {:type :unary :op ...} and {:type :binary :op ...} and a defmulti expr-op
13:51Chouser_(derive ::any ::unary)
13:52pstickneI do see how this helps :(
13:52pstickneI was wanting to match (defmethod expr-op [:binary :default] [expr] (bin-lookup (expr :op)))
13:53psticknein this case I could reduce the scope of the match,
13:53eeeis he saying "nil punting?"
13:53thickey_nil punning
13:53psticknebut then (defmethod expr-op [:unary "-"] [_] -) doesn't work
13:54slashus2pstickne: What does your defmulti definition look like
13:54pstickne(defmulti op-lookup (fn [expr] [(type expr) (expr :op)])) ;- non-working way
13:55eeei just googled nil-punning. anyone got a quick definition?
13:56pstickne(I've been using expr-op in place of op-lookup in the channel)
13:56pnkfelixI infer its CL's use of nil to denote many different conditions, dep on context
13:56SethTisueI think it refers to code that to be a little more concise assumes an empty list (or sequence, I guess? don't understand the sequence stuff yet) counts as false in a boolean context
13:57thickey_he will probably touch on nil punning again
13:57Mechow big can the heap space grow? i've had out of memory errors without getting anywhere close to actually being out of memory
13:57Chouser_slashus2: I describe a bit of it here: http://blog.n01se.net/?p=39
13:58eeedoes (seq eos) mean empty list?
13:58Chouser_Mec: java has command-line args to set memory limits
13:58eee,(println "hello")
13:58clojurebothello
13:58eee,(println first '(1 2))
13:59clojurebot#<core$first__3090 clojure.core$first__3090@d81cda> (1 2)
13:59eee,(println (first [1 2]))
13:59clojurebot1
13:59eee,(println (first (seq eos)))
13:59clojurebotjava.lang.Exception: Unable to resolve symbol: eos in this context
13:59eeeoh I thought that was a real thing
14:00scgilardi(seq eos) -> nil means that "the value you get when you ask for more and the sequence is exhausted", when passed to seq, will produce nil
14:00eee,(println (first (seq ())))
14:00pnkfelixI think its a placeholder for some end-of-sequence
14:00clojurebotnil
14:00eeeyeah
14:00pnkfelixand such end-of-sequences have many different posible representations
14:01eee,(println (first (list 1 2 3)))
14:01clojurebot1
14:01eeeis there a different way to get a list than to say list?
14:01pstickne,'(1 2 3)
14:01clojurebot(1 2 3)
14:01pnkfelixIs there an apropos function?
14:02eee,(println (first ,'(1 2 3)))
14:02Chouser_,(seq (list))
14:02clojurebot1
14:02clojurebotnil
14:02scgilardi,(find-doc "ns-")
14:02Chouser_,(seq ())
14:02clojurebot------------------------- clojure.core/ns-aliases ([ns]) Returns a map of the aliases for the namespace. ------------------------- clojure.core/ns-imports ([ns]) Returns a map of the import mappings for the namespace. ------------------------- clojure.core/ns-interns ([ns]) Returns a map of the intern mappings for the namespace. ------------------------- clojure.core/ns-map ([ns]) Returns a map of all the mappings
14:02scgilardiwhoops
14:02clojurebotnil
14:02Chouser_:-)
14:02eeeconj does different things depending on collection?
14:02pnkfelixhmm. Looks like find-doc itself loks like a nice apropos. :)
14:03Chouser_eee: yes
14:03eeethat seems to contradict the F*I thing to me
14:03pnkfelixoh but find-doc matches the doc-strings (as well as the identifiers (?))
14:03Chouser_pnkfelix: yep
14:04SethTisue,(conj (1 2) 3)
14:04clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
14:04SethTisue,(conj '(1 2) 3)
14:04clojurebot(3 1 2)
14:04SethTisue,(conj [1 2] 3)
14:04clojurebot[1 2 3]
14:04SethTisueI'll need to get used to that...
14:04Chouser_,(conj {:a 1 :b 2} [:c 3])
14:04clojurebot{:c 3, :a 1, :b 2}
14:05SethTisuehow come seq is a no-op on lists, but not on vectors?
14:06SethTisue,(class '(1 2 3))
14:06clojurebotclojure.lang.PersistentList
14:06SethTisue,(class (seq '(1 2 3))
14:06clojurebotEOF while reading
14:06SethTisue,(class (seq '(1 2 3)))
14:06clojurebotclojure.lang.PersistentList
14:06SethTisuebut then
14:06SethTisue,(class [1 2 3])
14:06clojurebotclojure.lang.LazilyPersistentVector
14:06SethTisue,(class (seq [1 2 3]))
14:06clojurebotclojure.lang.APersistentVector$Seq
14:07pnkfelixSethTisue: perhaps to support laziness?
14:07eeehappens to be
14:07SethTisueohhhh
14:07pnkfelixSethTisue: building a vector would requiring traversing the whole structure...
14:07SethTisueto support efficient iteration
14:07Chouser_yes, efficiency, not laziness
14:08pnkfelixah okay
14:08eeewhy can you make a vector like this: [1 2 3] but not a list like (1 2 3) . . . because clj doesn't know you aren't trying to eval . . . but it's asymmetric
14:09scgilardisymbols and lists don't evaluate to themselves
14:09scgilardithe're special that way
14:09Chouser_eee: yes, because you need *some* way to ask for a fn call
14:09Chouser_lists are it.
14:09cmvkk '(1 2 3) is easy enough
14:09Chouser_but (list ...) and (vector ...) are symmetric
14:09eeeshould have been like this: v(1 2 3) and l(1 2 3)
14:09eeehow nice
14:10eeenow I can have s(1 2 3), too
14:10DavidSJHow does (:b m) work?
14:10DavidSJIs :b callable? And if so, is that unique to keywords, or what?
14:10cmvkkkeywords are functions of their maps.
14:10eee,'(1 2 3) ... I'll have ti remember that
14:10clojurebot(1 2 3)
14:10DavidSJOK, but can't maps have keys that aren't keywords?
14:11cmvkkyeah, in that case you can't call a map by its key.
14:11DavidSJAh, thanks.
14:11cmvkkyou can do (m :b) though, for any key
14:11Mec,('a {'a 2})
14:11clojurebot2
14:11eee(list [1 2 3])
14:11DavidSJok
14:11eee,(list [1 2 3])
14:11clojurebot([1 2 3])
14:11eeenope
14:11eee,(vector 1 2 3)
14:11clojurebot[1 2 3]
14:12SethTisueso (:b m) and (m :b) mean the same thing?!
14:12Mecyes
14:12cmvkkeffectively
14:12SethTisuewhoa
14:12Chouser_SethTisue: when m is a map, yes
14:12pnkfelixSethTisue: in a context where m denotes a map object? Appearso
14:12Chouser_if m is nil, (:b m) returns nil (m :b) throws an exception
14:13eeedoesn't seem right that they are same . . . because map is not always a bijection
14:13cmvkki'm still annoyed that using cons stops the result from being a list
14:13Mecis the reader just checking if either expression is a map?
14:13Chouser_Mec: no, it's a runtime eval thing, not reader
14:13scgilardi,(:my-key 3)
14:13clojurebotnil
14:13DavidSJIs there sometimes confusion of the sort (if x ...), where x is expected to be False or true, and is sometimes nil?
14:14Mec,('a 3)
14:14clojurebotnil
14:14Mecweird
14:14DavidSJBut where nil *should* be treated as the true case?
14:14Chouser_eee: we're reversing the args of the lookup, not the key/val order of the entries
14:14scgilardinil can never be treated as the true case
14:14eeeoh
14:14eeei get it
14:14cmvkkyou can do (or x (nil? x)) I guess
14:15eeeso now what about cons?
14:15eeeyou lose that it was a list?
14:15cmvkk,(list? (cons 'a (list 'b 'c)))
14:15clojurebotfalse
14:15eeewhat is the type then?
14:15cmvkkCons
14:15DavidSJRight, cmvkk, but is that a mistake that occurs often?
14:15DavidSJdue to there being two false values
14:16cmvkki can't think of a situation where you'd want nil to be true right off the bat
14:16DavidSJi.e. someone forgets to account for that possibility
14:16DavidSJok
14:16SethTisuehowever
14:16cmvkkpredicates generally return true or false, and non-predicates typically don't return false that often
14:16SethTisue,(list? (conj '(1 2) 3))
14:16clojurebottrue
14:16SethTisuewhat is cons, then?
14:17pstickne,(cons? (cons 'a (list 'b 'c)))
14:17clojurebotjava.lang.Exception: Unable to resolve symbol: cons? in this context
14:17pstickneI lose :p
14:17cmvkk,(instance? clojure.lang.Cons (cons 'a (list 'b 'c)))
14:17clojurebottrue
14:19DavidSJ,(instance? Cons (cons 'a (list 'b 'c)))
14:19clojurebotjava.lang.Exception: Unable to resolve symbol: Cons in this context
14:19DavidSJoh, it's clojure.lang
14:19DavidSJnot Java.lang
14:19eeecan you downcast?
14:19DavidSJ:)
14:19eee(seq 1 2 3)
14:19eee,(seq 1 2 3)
14:19clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$seq
14:20SethTisueapparently cons is a sequence thing, not a list thing
14:20eee,(seq ,'(1 2 3))
14:20clojurebot(1 2 3)
14:20cmvkkyes.
14:20cmvkk,(seq? (cons 'a (list 'b 'c)))
14:20clojurebottrue
14:20eee,(list? (seq ,'(1 2 3)))
14:20clojurebottrue
14:21SethTisueOK, so cons works on all sequences. but in the case of lists, why doesn't it just do the same thing as cons in traditional Lisps?
14:21Chouser_SethTisue: might be a good one to ask aloud. :-)
14:21cmvkki think it's more efficient that way
14:25SethTisueI'm looking through the documentation
14:25SethTisueand I see that count is O(1) on lists
14:25SethTisuemaybe that's the efficiency issue
14:25SethTisuein CL and Scheme, getting the length of a list is O(n)
14:25eeeso you may have to find out the type of a sequence
14:25eeeto figure out what to do
14:26eeethere's no analogue to template specialization
14:26eee...or ..."what's the analogue to template specialization?"
14:27Chouser_eee: if you're sure you want to do something different for one type than another, you may want to use a multimethod or check the arg type manually.
14:27Chouser_eee: I think the point is that this happens less often than you might think.
14:27MecSethTisue: count is O(n) if a list hasnt been counted yet
14:27scgilardiamortized O(1)
14:27Chouser_Mec: PersistentLists are always counted
14:27DavidSJI suppose guaranteeing O(1) would be impossible in Scheme or Lisp because the CDR can change without the cons knowing.
14:28eeechecking the type is a runtime check
14:28Chouser_DavidSJ: excellent point
14:28pstickneeee: except a multi-method can't match any on more than one param :(
14:28Chouser_pstickne: not true
14:28SethTisuethe doc simply says, count is O(1). no qualifications, just a flat out statement. it sounds like they are counted when constructed
14:28Meci meant sequence not lists, a lazy sequence may not have been counted yet
14:28pstickneChouser_: (defmethod x [:default :something] ...? ) ;- what am I missing?
14:28scgilardiChouser_ is correct. It's O(1). I was thinking of the hash code which is calculated when needed.
14:30eee,(countedp ,'())
14:30clojurebotjava.lang.Exception: Unable to resolve symbol: countedp in this context
14:30Mec,(let [x (range 100000)] (time (count x)) (time (count x)))
14:30clojurebot100000
14:30Chouser_pstickne: you can match, you just can't have a default for one of the multi-args but not all when you have an open set of types
14:30clojurebot"Elapsed time: 0.02 msecs" "Elapsed time: 0.0060 msecs"
14:30Chouser_,(counted? ())
14:30clojurebottrue
14:30eee,(counted? ,'())
14:30clojurebottrue
14:30pnkfelixseems like count should be O(1) only for counted? things
14:30eeeahhhhh now I know what the controversy is
14:30Mec,(counted? (range 10))
14:30clojurebottrue
14:30eee() is broken
14:30SethTisueI guess I just got my answer on why Cons exists separate from IPersistentList. Cons is not counted so it's more space-efficient
14:30pnkfelixSince I just attempts to apply it to a cycle
14:31eeeshould be a function with no args including it's name
14:31eee() should return nil because it's a function.
14:31eeebut clj breaks that
14:32digash`() is not a function call
14:32Chouser_well, () could throw an error because you forgot to specify which function to call
14:32eeethat would work, too
14:32Chouser_but that's not very useful, so it's an empty list. :-)
14:32Mecthats nice to know, better than writing '()
14:33DavidSJ,(reversible? ())
14:33clojurebotfalse
14:33digash`() is more idiomatic, according to Rich
14:33DavidSJ,(reversible '(1 2 3))
14:33clojurebotjava.lang.Exception: Unable to resolve symbol: reversible in this context
14:33DavidSJ,(reversible? '(1 2 3))
14:33clojurebotfalse
14:34DavidSJ,(reversible? [1 2 3])
14:34clojurebottrue
14:34digash`the same as {} []
14:35Mec,(reverse '(1 2 3)
14:35clojurebotEOF while reading
14:35Mec,(reverse '(1 2 3))
14:35clojurebot(3 2 1)
14:35Mecso why doesnt reversible? work
14:35SethTisuereversible? asks whether its reversible in O(1), I think
14:35Mec(doc reversible?)
14:35clojurebotReturns true if coll implements Reversible; arglists ([coll])
14:36dreishWhether you can call rseq on it.
14:36dreish,(rseq '(1 2 3))
14:36clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Reversible
14:36SethTisue(doc rseq)
14:36clojurebotReturns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil; arglists ([rev])
14:36dreish,(rseq [1 2 3])
14:36clojurebot(3 2 1)
14:36SethTisueI'm still getting used to not assuming something is a list when I see parens in the repl output
14:37Mechow do you download from google code? the downloads is blank but there are deffinitly files under source
14:37SethTisue,(class (rseq [1 2 3]))
14:37clojurebotclojure.lang.APersistentVector$RSeq
14:37cmvkkyou have to use SVN, Mec
14:37dreishI just use Kevin O'neill's git mirror.
14:37Mecboo not current snapshot zips?
14:38cmvkkno such thing, as far as I know
14:38cmvkkjust latest release builds, and SVN or git
14:38dreishgithub has zips
14:38Chouser_sure there's a recent .zip release.
14:38dreishhttp://github.com/kevinoneill/clojure/tree/master and click on download
14:38Chouser_http://code.google.com/p/clojure/downloads/list
14:39digash`http://tapestry.formos.com/bamboo/browse/CLJ;jsessionid=C4BE2E3CBD3992711C615C7A575CB4A3
14:39eeeis there a "metadata-included-equal?" function?
14:40Chouser_no, though you could compare the metadata separately
14:40eeeor "(equal-including-meta?"
14:40Chouser_(and (= a b) (= ^a ^b))
14:40eeeoh
14:40Chouser_never seen that used or needed
14:40eeemaybe someone just thinks their objects are equal right now
14:40eeeand they just don't know about the bug
14:41dreishWhat bug?
14:41eeein their code
14:41dreishMetadata doesn't affect equality. That's pretty much the definition of metadata.
14:41eeethat they didn't remember that meta data not included in check
14:41dreishYou should not check metadata for equality.
14:41dreishIf you do, you're almost certainly misusing it.
14:42eeei can see your point
14:42eeetotally
14:42eeeotherwise it's not called meta data
14:42tewhoa shit. the hottest girl i went to high school with wants to take me out
14:42eeeit's just data
14:42tethis girl was just in playboy
14:42danlarkinte: *OT alarm*
14:43teexit, stage left
14:43tedanlarkin: i forked Madison, so zip your lip
14:43te;)
14:43selloutToo bad the channel's not on the projector at the moment.
14:43danlarkinte: cool! what'll you add?
14:43tedanlarkin: haven't read through the source much yet, but i'm excited to get in there and poke around
14:44tedanlarkin: only one problem
14:44teyou need to rename it Clabango
14:44danlarkinno can do
14:44eeei wonder if we get to fill out a survey
14:44tedanlarkin: awww why not?
14:44cconstantinewhat're you guys at?
14:45selloutILC
14:45scgilardi5 hour talk on Clojure by Rich at the Internation Lisp Conference, this year in Cambridge, MA
14:45cconstantineaahhh
14:45cmvkkwhat slide are you on
14:45scgilardi51-ish
14:45sellout54
14:46cmvkkso you're almost done
14:46eeei'm not paying enough attention now, i fear. . . .that we are chatting
14:46selloutcmvkk: I dunno ... we have over 2 hours left.
14:46tescgilardi: sellout: is there a channelo?
14:46Chouser_these are new slides
14:46teI wasn't formally invited
14:46cmvkkdifferent from the ones someone linked earlier?
14:47telink me please
14:47slashus2~clabango
14:47cmvkkjava interfaces? a la carte hierarchies?
14:47clojurebotclabango is http://github.com/danlarkin/madison/tree/master
14:47SethTisuesame as link I sent earlier
14:47Chouser_oh, um ... I guess these are the new ones on google group files
14:47SethTisuehttp://clojure.googlegroups.com/web/tutorial.pdf?gda=wpkXdz4AAAC2LrkjeC7f10uHiY7GOiyxfbmym9_39wWPz8-Z2OGMtMwgAOBOKqa5ZS2rRu2OVUrjsKXVs-X7bdXZc5buSfmx
14:47tedanlarkin: I know this is a low priority, but you might consider bundling the dependencies
14:47cmvkkit only goes up to 70, is what I meant. I assume after that there will be extensive Q&A
14:48teI think it'd do a whole lot for newbs
14:48cmvkkand maybe some ants unless that already happened
14:48selloutOr hands-on, maybe
14:48scgilardiHe mentioned giving the "state" talk for the last 90 minutes. Maybe those will be from another set of slides.
14:48danlarkinte: I will not bundle deps, I don't think it's the Right Thing To Do(TM(TM)
14:49tedanlarkin: I think you should give users the optiohn
14:49teoption
14:49te</opinion>
14:49danlarkinI have no plans to
14:49teI'll do it then :)
14:50eeei stayed up late cause i read that we'd be playing along and I had to set up my environment. anyone know if we'll be writing a program? I'm starting to guess not
14:50teClojure is still a pretty small community -- the "build a sweet dynamic website" tutorial is still the key to opening up any new lang's userbase IMHO
14:50cmvkki find it sad that all the cutting edge people care about anymore is building dynamic web apps.
14:51cmvkkthere's so much more to programming!
14:51pnkfelixeee: there's always the 30min break to spend hacking. :)
14:51eeesame here
14:51tecmvkk: i think in clojure's case building a dynamic web app can be very instructive as to how clojure works to build "stuff"
14:51teor the advantages to using it
14:51jhawk28there is some hard core p2p
14:52eeei actually thought he'd be walking us through programming . . . .and I almost asked if it was ok that I didn't have emacs yet
14:53teElitist attitudes and arrogant old developers continue to be a problem for the CL userbase
14:53pnkfelixeee: I am actually hoping to find someone to help me fix my emacs setup... the clojure-mode.el does not seem quite right in my context
14:53teHaskell has done a marvelous job of not sucking ass
14:53teClojure can do the same with a helping hand here and there
14:53teIMO
14:53p_lte: I haven't seen much of elitist attitude and arrogant old developers... but I heard it was like that few years ago...
14:54eeetalk != "tutorial"
14:54dreishte: Funny you should mention that. I pretty much expect Haskell to end up in the same place as CL in several more years.
14:54teMaybe it's changed, but I'll be damned if I still don't see the same old names on lisp blogs talking about how YOU'RE DOING IT WRONG!
14:55tedreish: save your prophecy
14:55tedreish: I respect your opinion, but I don't take much stock in prediction
14:55teespecially with tech in general
14:55Lau_of_DKdanlarkin, bundling dependencies it The Right Thing To Do (tm)
14:56dreishFine, whatever.
14:56teLau_of_DK to the rescue
14:56p_lte: Well, I avoid c.l.l and certain blogs and keep it to #lisp... the community there is much nicer :D
14:56jhawk28danlarkin:
14:56jhawk28danlarkin: is there a sample app to demonstrate Madison?
14:56Lau_of_DKWhat has given an inferior OS like Windows 95% marketshare? They bundle stuff and make it simple. Linux is greater in every aspect, but because we still have mainstreamed all the little tricks that we all use, its written of as "complicated"
14:56tewhy did Rails blow up?
14:56Lau_of_DKYou just put Madison in the category
14:57tethey showed you the blog webapp in a few lines
14:57tethat's why
14:57danlarkinjhawk28: no, not yet... it's not really ready for general use yet
14:57p_lLau_of_DK: windows bundless much less than 10yo linux distro...
14:57tep_l: that's another topic altogether
14:57tewhat Lau_of_DK is saying is essentially true
14:57Lau_of_DKtruely
14:57tesimple sells
14:58p_lte: I think what really made Windows such a success is that making apps for it wasn't hard
14:58jhawk28danlarkin: have you been able to do anything with dynamic database models?
14:58dreishLau_of_DK: It has high market share because developers target it, and developers target it because it has high market share. MS has historically focused more of its efforts on the developer side of that than on making Windows pleasant to use.
14:58Lau_of_DKp_l youre off topic
14:58danlarkinLau_of_DK, te: I think a framework bundling deps is a mistake. An end user program, sure, but not a program for programmers
14:58Lau_of_DKForget Windows, forget Linux, focus on manipulating danlarkin into bundling all those dependencies
14:59teif this is an academic exercise for you then sit back and enjoy the ride, but personally I would like to see Clojure gain some developers and grow up into a beautiful lang
14:59dreishLau_of_DK: You brought it up. :-P
14:59Lau_of_DKAnd now Im bringing it down
14:59teClojure has so much promise. The decisions of developers today will affect the potential devs of tomorrow
14:59cmvkkthis is free software, danlarkin doesn't need to bundle anything. someone can just fork the project, pull every update from the original, and make a bundled-with-deps version.
14:59jhawk28cmvkk: use apache ivy for deps
15:00SethTisuehungry plumber?
15:00tecmvkk: I'm doing it, but it doesn't usurp the fact that bundling and making things newb-friendly will help Clojure in the long run
15:00danlarkinjhawk28: Madison doesn't have the "M" part of MVC yet. It's coming though, for sure. John Hume's clj-record looks very interesting
15:00Lau_of_DKFine fine... I have 'Clabango' on Github, I can make that a bundled Madison
15:00cmvkkheh
15:00teLau_of_DK: booya!
15:00Lau_of_DKMan - whats keeping Open Source down? Lazy developers
15:01eeei'd just prefer to see it, vice just hear about it.
15:01Lau_of_DKNot going the last 5 mm to complete the job
15:01digash`,(isa? String Object)
15:01teLau_of_DK: was that in jest?
15:01clojurebottrue
15:01Lau_of_DKLook at ClojureQL for instance
15:01teLau_of_DK: I hope you're not kidding, because I agree
15:01pnkfelixSethTisue: multiple inheritance
15:01eeeso many practical questions would pop up
15:01Lau_of_DKte, Im not kidding, and ClojureQL is my project, so Im guilty also :(
15:01teNERDS: MARKET YOUR MIND. </PSA>
15:02cmvkkbut Lau...those 5mm are *boring*
15:02Lau_of_DKAlthough I will say, ClojureQl is quite fantastic in its own right
15:02teI really just want to choke when I think about how many great projects there are out there that don't know a goddamn thing about helping people use their code
15:02Lau_of_DKYea its a shame, although Compojure has really picked up the pace lately
15:02teYeah -- very big surprise tbph
15:03Lau_of_DKAnd technomancy's little tricks with Concourse was just fantastivc
15:03teI didn't expect it
15:03Lau_of_DKminus the v though
15:03teamen
15:03teTechnomancy == pure awesome.
15:03Lau_of_DKYea, pillar of the community
15:03teLanguages blow up because of people like that, and what they do isn't so special
15:03tethey just instruct people on how to use their cool ideas
15:04telike Lau_of_DK said: the extra 5mm
15:04Lau_of_DKIts just like that :)
15:04pnkfelixis there a way for me to install a hierarchy I have created as the global hierarchy? (sounds dangerous i admit)
15:05teLau_of_DK: we should start a site that basically focuses on writing documentation for open source projects
15:05teand reward people who contribute with something
15:05Lau_of_DKAnd write it in Compojure just to punish Danlarkin for his i'll choises
15:05telol
15:05Lau_of_DKte... thats actually a very very awesome idea
15:05Lau_of_DKBest Ive heard all year I think
15:06ieureHow can I parse XML from a string?
15:06Lau_of_DK"This site was written in Compojure, simple because Danlarkin needs to be taught a lesson"
15:06telol
15:06Lau_of_DKieure, zip-filter
15:06teLau_of_DK++
15:06danlarkinhahah
15:06danlarkinyou'll get yours!!
15:06teokay but serious dan -- bundle your code -- don't be an MITurd
15:06Lau_of_DKte, I'll get to work, on getting a virtual server set up somewhere and get compojure launched on it
15:06Lau_of_DKhaha
15:07Lau_of_DKclojurebot: danlarkin is an MITurd
15:07clojurebotAck. Ack.
15:07teLaulol
15:07Lau_of_DKdanlarkin, Its up to you to redeem your image
15:07Lau_of_DK...by way of bundling
15:07danlarkinclojurebot: forget danlarkin
15:07clojurebotI forgot danlarkin
15:07danlarkinredeemed!
15:07Lau_of_DKhmm, nope, till a turd :)
15:07Lau_of_DK+s
15:07telook i don't care if you bundle it -- but update your docs with how to get Madison running for the complete and utter noob
15:07tethat's how you get on Hacker News
15:07tethat's how you get on reddit, etc.
15:08tethat shit grows languages
15:08danlarkinte: but I don't want to get on HN/reddit
15:08cmvkkto be fair, it's probably too early for that
15:08Chouser_ieure: (clojure.contrib.lazy-xml/parse-trim (java.io.StringReader. "<foo />"))
15:08Lau_of_DKcmvkk, I'll drop you a private MSG next time we want your oppinion, thanks in advance :)
15:08teyeah I guess I'm just speaking in principle -- I repsect dan's judgement-- the guy is obviously damned smart
15:08cmvkkdon't worry, i'll give it no matter what.
15:08pnkfelixI'm getting an exception when I invoke (derive :a :b)
15:08Lau_of_DKhehe
15:08Lau_of_DKGood :)
15:08danlarkinte: the project is not complete. "utter noobs" trying to use madison would just be disappointed
15:08pnkfelix,(derive :a :b)
15:08clojurebotjava.lang.Exception: Assert failed: (namespace parent)
15:08ieureChouser_, I think zip-filter might be the way to go, since I need to traverse the tree to extract a value.
15:08Chouser_pnkfelix: (derive ::a ::b)
15:08tedanlarkin: yeah I understand man -- just trying to impart the little wisdom I have
15:09Chouser_ieure: you'll still need to parse the xml string first
15:09pnkfelixoh I see; I misparsed the documentation
15:09pnkfelix(thought "namespace-qualified" only applied to the symbol)
15:09tedocs = win, getting started step-by-step = win
15:09tethose things are so incredibly important to the success of a community
15:11Chouser_I wonder if we could do an ad-hoc workshop after the talks.
15:11cmvkkwhat would you do?
15:11eeei would LOVE that
15:11eeeplease!
15:12Chouser_i dunno. do what you want, I guess. projecteuler?
15:12eeewhen
15:12cmvkkants? the ant farm? it's clojure's killer app.
15:12telol fuck that
15:12eeei want to start with a blinking curser
15:12cmvkkheh
15:12eeeand we do something that makes stuff pop up on the screen
15:12eeefrom thin air
15:12tethose are called dioramamas
15:12eeenot look at existing code
15:12tedioramas
15:13cmvkkcivil war battle dioramas
15:13eeetalk about something . . .then code it
15:13tei dont like that idea
15:13eeebattle . . . .we can implement battleship
15:13eeeis clojure
15:13tehow about talk THROUGH coding something
15:13eeein clohjure
15:13eeethat's what I mean
15:13tecome up with an intersting project, and then everyone work together to suggest how to do it
15:13teexplain why
15:13eeelet's make multiplayer battleship
15:14cmvkkthat might take longer than the time you have
15:14Chouser_"pop up on screen" implies GUI? that implies time spent on java lib spelunking
15:14Lau_of_DK~sofiaba?
15:14clojurebotsofiaba is http://wiki.github.com/Lau-of-DK/sofiaba
15:14eeethat's what he argues make clojure useful
15:14Lau_of_DKeee Could you contribute a mid-sized battlecruiser please?
15:15teLau_of_DK: only if you say "Battlecruiser operational" in a russian accent
15:15Lau_of_DKOh I will :)
15:15te(in a gay way)
15:16te(im a maniac, maniac...)
15:16Lau_of_DKI think we just broke #clojure
15:17teLau_of_DK: will you be my new best IRC friend
15:17Lau_of_DKNo Chousers much better at that stuff :|
15:18teLau_of_DK: aw come on
15:18tewe share the same open source politcal belief system
15:18tewe must be friends
15:19tehola durka42
15:19durka42hi te
15:19tehow goes it
15:20durka42not bad
15:20durka42heading back to school
15:20teglad to hear it
15:20teoh really
15:20tei just finished with spring break as well
15:20teUW Madison
15:20teyou?
15:20durka42swarthmore
15:20durka42was just visiting family for the weekend
15:20teah great school
15:21durka42i agree
15:21eeewhen we doing the lab?
15:22eeeor just chatting?
15:22eeei'm in
15:23Chouser_I don't know if we can use this space
15:23technikthat was unintentionally funny
15:29eeewhy this not work? (new java.awt.JFrame)
15:29ieureGetting this when I (use 'clojure.contrib.zip-filter) in the REPL: "java.lang.IllegalStateException: descendants already refers to: #'clojure.core/descendants in namespace: weevil (NO_SOURCE_FILE:0)"
15:29ieureIdeas?
15:30SethTisuejavax.swing.JFrame or java.awt.Frame
15:30Chouser_ieure: yeah. core added 'descendants' after zip-filter already had it
15:30Chouser_you might want (require '[clojure.contrib.zip-filter :as zf])
15:31eeeSeth . . . not work
15:31eeemy type ahead says it should
15:32eeeuser=> (new java.swing.JFrame "sdgsdfg") java.lang.ClassNotFoundException: java.swing.JFrame (NO_SOURCE_FILE:11)
15:32pnkfelixstill need javax
15:32eeeawt Frame worked
15:32pnkfelixswing is in javax. not java
15:32SethTisuejavax.swing not java.swing
15:33ieureChouser_, Okay, cool. Thanks.
15:33ieureSorry about the n00b questions.
15:33eeeoh
15:33eeemy type ahead lies
15:34Chouser_ieure: not a problem
15:35eeei guess there's a bug in the rlwrap
15:39hiredmanbusy morning
15:51hiredman~ping!
15:51clojurebotPONG!
16:00eeehello
16:01hiredmanwhatever you do don't say that to clojurebot
16:01eeenow that I can make a JFrame . . . what's the most succinct way to set it visible
16:01pnkfelix.show method ?
16:01eeesetVisible(true)
16:01eeethis is what I was hoping to learn today
16:01eeepractical hands on
16:01hiredmanI usually make JFrames using a doto
16:01eeecool
16:01pnkfelixbut that's Java library stuff; its nothign to do wit hClojure
16:02digash`eee: take a look at the ant.clj example
16:02eeewell, it's Rich's arg for putting it in jvm
16:02hiredman,(doto (JFrame.) (.setSize 800 600) (.setVisible true))
16:02clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: JFrame
16:02eeevice making new lang for PLT-Scheme
16:02hiredmanclojurebot: ignore that
16:02clojurebotTitim gan �ir� ort.
16:02eeeso that seems like what we should cover . . . how it's actually useful
16:03eeethanks
16:03pnkfelixI think the Java interop slides were meant to cover that
16:03DavidSJIs there something like SLIME for Clojure?
16:03eeeslides slides
16:03pnkfelixsomeone who knows Swing (e.g., not me) would be able to take that and run with it
16:03hiredmanDavidSJ: there is slime for clojure, which is sort of like slime :P
16:03eeesome people need to be walked through stuff
16:03DavidSJoh, cool
16:03eeeme for e.g.
16:03pnkfelix(this is why I was careful to clarify that I knew Java the lang but not Java the libraries)
16:03eee"tutorial"
16:03hiredmanbut I am not an emacs user so I cannot really help with that
16:03eeei am not either
16:04DavidSJI got this in my *inferior-lisp* when I tried na�vely though: user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)
16:04eeei am just using rlwrap
16:04DavidSJDo I need to update my slime?
16:04DavidSJoh, ok
16:04DavidSJI guess I'll ask Google.
16:04SethTisueI'm reading ant.clj and learning a lot
16:04hiredmanI imagine all the emacs clojure guys are at ilc
16:04eeehow would that be used with the "new" operator>
16:05hoeckDavidSJ: http://github.com/jochu/swank-clojure/tree/master
16:05pnkfelixI would actually like for one of the emacs clojure guys to help me with me config
16:05hiredmaneee: (new JFrame) and (JFrame.) are the same
16:05eeecool! my first productive use of clojure
16:05hiredman,(macroexpand '(JFrame.))
16:05eeesomething someone can see!
16:05clojurebot(new JFrame)
16:05pnkfelixbut I forgot until just now, so I guess I will wait until after 3rd sesion to ask
16:05DavidSJGreat hoeck, thanks.
16:05DavidSJlet's try that...
16:06hiredmansymbols with a '.' at the end are treated as calls to new
16:06hiredmansymbols with a '.' at the begining are treated as method calls
16:07SethTisuepnkfelix: I have swank-clojure and slime up and running in Emacs on my Mac. I'm not an expert on it obviously (1st day using it) but I could show you my config.
16:08eeethanks hired
16:08eeethat helps me remember it
16:08pnkfelixSethTisue: okay I would appreciate that; lets talk at 5pm?
16:08thickey_http://clojure.googlegroups.com/web/StateAndIdentity.pdf
16:09hiredmanis this talk #2?
16:09pnkfelixSethTisue: caveat: I am not a slime user so getting that set up may be more hell than its worth. We'll see at 5pm
16:09SethTisuepnkfelix: sure. I'm in back row, on aisle, plaid shirt, mac laptop.
16:09thickey_hiredman: session 3
16:09cmvkkif i put the head of a lazy-seq inside an atom, but there aren't anymore references to the atom, the whole thing will be garbage collected, right?
16:10Chouser_cmvkk: sure
16:10Chouser_cmvkk: an atom is just another object
16:10cmvkkokay, that's what I thought
16:10cmvkkI'm running out of heap space and it isn't immediately apparent to me why
16:11cmvkkbut what i'm doing new is introducing a construct that uses atoms to allow for mutual recursion between lazy-seqs.
16:18eeehow do I erase my type-ahead history in rlwrap?
16:19eeeclj script
16:21Chouser_eee: maybe ~/.java_history ?
16:22eeei found it
16:22eeeits
16:22eee.jline-clojure.lang.Repl.history maybe
16:22Chouser_eee: you can set it via rlwrap command-line
16:22Chouser_jline!?
16:22eeeno
16:22eeethat was before
16:23eeeall this stuff is on the web site
16:23eeeso far
16:24pnkfelixeee: reading web site was (unfortunately) not prereq for attendance
16:24eeeyup
16:24eeewell said
16:26eeei'd like to see how to set up the ant simulator
16:26eeeso I can mess with it
16:26eeethink we'll get to that?
16:27Chouser_should be plenty of QA
16:28eeei like how he just explained that. time is a dimension, too. and what's cool, is you can trace it back by recording all the state transitions
16:28thickey_next Clojure t-shirts: "The future is a function of the past."
16:29eeegood idea!
16:29Chouser_thickey_: excellent.
16:29Chouser_or "time happened"
16:30agriffis"time happens"
16:30eeedecision making from snapshots is called "causal inference error"
16:32mattreplthickey_: awesome! is that really going to happen? I'd be happy to pitch in to cover up front costs, and I recommend american apparel tshirts, very comfy
16:33Chouser_mattrepl: http://www.zazzle.com/clojure
16:34Chouser_(clojure 'lisp)
16:34eeetest test
16:34eeecool
16:34Chouser_^^^ the future is a function of the past
16:34mattreplChouser_: thanks
16:34thickey_=)
16:34eeeslow network
16:35teI'm buying "DON'T BE SO EAGER"
16:35tebrilliant
16:35eeethe eager one is the best
16:36teI have a good one:
16:36te"Call Paul Graham, we built a better Arc"
16:36mattreplexcellent, looks like zazzle has AA shirts available
16:36te-Clojure-
16:36mattreplouch
16:36durka42ooh clojure buttons
16:37tehas anyone here read Hackers and Painters?
16:37teto those of you who have read it: Did you feel like a whiny 18 year old while reading the first 4 chapters?
16:38teP. Graham whines too much about high school.
16:38teGrow a pair, nerdboy.
16:41cmvkkhe's too busy being a millionaire. can't fault him for that...
16:41tei really liked PG until I realized he doesn't know how to stfu
16:41te\the guy blogs about the most inane shit
16:42pnkfelixilc: how wide can the branching get here?
16:42pnkfelixilc: 32 ways in worst case? Is that right?
16:42telog32n
16:43Mecwhen adding a map to a funciton definition, can you not also have a single arg version?
16:43hiredmanhuh?
16:43te...
16:43Chouser_Mec: adding a map in what way?
16:45gnuvince_~seen cgrand
16:45clojurebotcgrand was last seen joining #clojure, 744 minutes ago
16:45hiredman(first time that has ever worked)
16:46Mechmm i see them doing it in the waterfront code but i cant get it to work at all
16:49hiredmanMec: example please
16:50eeewf never worked at all for me
16:50eeei gave up
16:50Mecya i just get an error, let me put one of their functions up on pastey
16:50Chouser_"you are not the king of time" --clojure
16:50lisppaste8Mec pasted "untitled" at http://paste.lisp.org/display/77428
16:50thickey_i love that he said "i am" right after that
16:51eee"the King of not being the King of time"
16:51Chouser_thickey_: huh, missed that.
16:51Chouser_oh, the meta-data attr-map arg of defn
16:51Chouser_Mec: that's what you're talking about?
16:52hiredmanMec: so you are trying to attach test metadata?
16:59Mecah thats metadata, ok nvm then
16:59eeeI wonder what data structures PostgressQL and Oracle use
17:00eeecan use a db with ANY language
17:00Chouser_eee: in memory or on disk?
17:00eeeeither way
17:00eeedb supports both
17:02p_lI dunno about Oracle, but Postgres ultimately boils everything to object database afaik
17:03p_lpossibly the same for Ingres
17:10slashus2I know this might be a silly question, but what is the best way to create an event-driven API in clojure? (e.g. twisted, pircbot)
17:11StartsWithKthere is (assoc-in {:a {:b 3}} [:a :b] 4) but, why is there no (dissoc-in {:a {:b 3}} [:a :b]) -> {:a {}}
17:11StartsWithKand how is the best way to do it then
17:11slashus2StartsWithK: Just use update-in
17:12slashus2and use dissoc
17:12StartsWithKupdate will make :b nil at best
17:13StartsWithKdissoc will work only for first level
17:14eeehe's right. oracle works . . . used every day
17:14slashus2StartsWithK: (dosync (alter memo-database update-in [channel] dissoc sender)) something like this
17:14agriffishttp://clojure.org/sequences refers to fnseq which doesn't appear on http://clojure.org/api ?
17:14eeedoesn't that make regular old java competitive in the future if used with oracle?
17:15Chouser_agriffis: it's a new special form
17:15thickey_(update-in {:a {:x {:q 1 :r 2}}} [:a :x] dissoc :q)
17:15agriffisChouser_: ah, the link is wrong then
17:15Chouser_but it's not documented on the special forms page yet, either. :-/
17:16StartsWithKthickey_: thansk, that helped
17:16StartsWithKks*
17:16thickey_StartsWithK: np
17:20eeewait a sec
17:20eeeis ensure a type of lock?
17:21slashus2~def ensure
17:21eeevalue will not change for how long?
17:21Chouser_eee: no, not a lock -- it's a request to the current transaction
17:21eeeensures the value doesn't change
17:22eeesounds like a lock to me
17:22Mecwhat's the point of using find?
17:22Chouser_it asks that if the ensured ref changes (by something else) before the end of this transaction, retry this transaction please
17:22cmvkkit brings it in as part of the dosync...it's like setting a ref to itself.
17:22eeei see
17:22eeeretry once?
17:22sellouteee: no, it means if there's another transaction that modifies it while the current transaction is running, one fo them will fail.
17:22sellout(fail, and retry)
17:23slashus2What is a concrete example of needing this?
17:23eeei'd have to work through a scenario . . . too casually defined right now for m
17:23eeee
17:24eeeif you open a transaction
17:24eeeand then I open a transaction
17:24eeeand then I ensure
17:24eeeand then you try to change data
17:24eeewhat happens
17:24eeeI retry
17:24eeeor I win
17:24eeeand you retry
17:24Chouser_yes
17:24selloutone of those two ;)
17:25eeegreat
17:25eee:(
17:25eeei don't get it
17:25sellouteee: it's unimportant which.
17:25eeewell I did an ensure
17:25eeeand you didn't
17:25eeeso I don't see what it's for
17:25pnkfelixeee: you can't observe the change during the txn
17:25sellouteee: an ensure is for if you read, but don't modify, a value.
17:25slashus2Is there an example of code using ensure somewhere?
17:26slashus2So just derefing a ref inside of a transaction doesn't ensure that you will see it in a consistent state?
17:27eeewho knows
17:27selloutCorrect.
17:27eeeyou have to read the docs. this isn;t a tutorial
17:27eeeeven tho on tutorial day :)
17:27Mecslashus2: what do you mean by event-driven api?
17:27Chouser_slashus2: no, it'll be a consistent state -- at a snapshot point in time
17:28Chouser_slashus2: it may have changed since, but unless you care, don't 'ensure'
17:28selloutslashus2: It works like selects do in most DBs.
17:29eeeensure sounds like double-checked locking bug
17:29eeei look at state
17:29eeeand it's good
17:29eeeso then I do something
17:29eeeassuming it's still good
17:29eeeso for that to work, your transaction should fail
17:29pnkfelixeee: like the example of wanting to make sure that at most one account goes to negative balance
17:30slashus2Mec: I mean like pircbot or a GUI event binding.
17:30Mecjust like a way to register/call events and whatnot?
17:31slashus2Mec: I guess call backs would be the way.
17:31lisppaste8Mec pasted "Events" at http://paste.lisp.org/display/77430
17:31Mecthats the simplest way i can think of to concurrently do events
17:31slashus2neat
17:32slashus2Why did you use an atom instead of a ref?
17:33Mechellifiknow, that's how memoize is implemented
17:33Chouser_uncoordinated. that looks correct to me
17:34Mecwhats the diff between ref and atom?
17:34SethTisueis an atom like a ref where if you want to change it the change implicitly is wrapped in a little transaction?
17:34Chouser_SethTisue: semantically that's pretty close. you need a transaction and refs when you have more than one ref involved in the transaction.
17:35slashus2So when you don't want serial events?
17:37Chouser_changes to an atom are serialized, but only on the one thing
17:37slashus2It won't be multiple all or nothing, just one.
17:38Chouser_if I want to update two refs in one transaction, such that either both or neither happen, I must use refs. If I only ever care about one at a time, I may be able to use atoms.
17:39slashus2Is it more efficient if you are only going to be modifying one ref to just use an atom?
17:40Chouser_yes, but it's a property of the reference type itself, not the change action (the transaction). So if this particular reference will ever be coordinated with others, it should be a ref -- otherwise an atom is fine.
17:41slashus2neat
17:41slashus2hence the name: atom
17:41slashus2Makes perfect sense now.
17:41Chouser_great!
17:42slashus2Chouser_: Can you think of an example of where using ensure is mandatory? I have played around with refs, but I haven't ever used ensure before.
17:46slashus2I didn't see an example of using ensure in Programming Clojure.
17:50slashus2Would you use it like (ref-set ref (ensure ref))
17:55dreishslashus2: When you read a ref within a transaction, you get its value at the instant your transaction started, but there's no guarantee it'll have the same value at the instant the transaction commits. ensure guarantees that. (Apologies if someone has already explained that.)
17:56slashus2Otherwise the transaction will retry.
17:57dreishRight.
17:57slashus2ensure keeps the transaction from having to retry?
17:57dreishNo, it causes the transaction to retry if someone else has changed the value you read.
17:57slashus2I was under the impression that it did that automatically when that happens anyway.
17:57dreishNo, not if you just read with deref.
17:58dreishderef is a fetch-and-don't-care-what-happens-afterward.
17:58slashus2In that case, when does a transaction retry?
17:58slashus2without using ensure
17:58dreishalter
17:59slashus2So I only need to use ensure outside of alter?
17:59dreishYou only need to use ensure if the end state of your transaction would be invalid if the ref in question changed after you read it.
18:00dreishThe canonical example for why you wouldn't care if things change is a sales report as of an instant in time, where you just want to read things but it is understood that their values will keep changing after that instant.
18:01dreishA less business-y example would be writing a backup to disk.
18:01slashus2You just want to see a snapshot.
18:01slashus2Don't care what happens.
18:01dreishI can't think of any easy-to-describe use cases where you actually _would_ care about the value; they're usually tied up in the logic of a more complex system.
18:02dreishcare about the value not changing, that is
18:02slashus2dreish: Yeah, I can't think of one either, that was the root of my confusion.
18:02dreishYes, I agree it is all confusing. :) It has taken me a few months to really get comfortable thinking in terms of transactions on variables.
18:03slashus2It is sort of a black box at first.
18:03dreishBut I could see right away that it was useful.
18:03dreishThe biggest problem I had was that I couldn't believe it was actually as magical as it really is.
18:04slashus2Using ensure would lead to more contention?
18:04dreishThe idea that the moment you enter a dosync, all refs are instantly frozen from your point of view, even if you have tens of thousands of them -- it seemed like it couldn't possibly be right.
18:04dreishslashus2: More retries, but in my experience still not that many.
18:04slashus2dreish: You have used ensure before in an application?
18:05dreishI have a SQL persistence layer that represents a table as a lazy-loaded hash of refs, and I wrote a test function that creates N threads and has them all hammer the same row, doing an atomic get-and-increment.
18:05dreishWith 100 threads, I only see maybe 1 retry out of around 200 transactions.
18:07slashus2This is what ensure does to a ref: public void public void touch(){ LockingTransaction.getEx().doTouch(this); }
18:07slashus2
18:08slashus2It does lock(ref)
18:08slashus2So ensure does lock it
18:09slashus2Puts a write lock in it.
18:09dreishLooks that way.
18:09slashus2I am looking at LockingTransaction.java
18:09slashus2very interesting
18:10dreishIt is, but as rhickey always says, don't count on any implementation details as guarantees of a specific behavior.
18:10Mecwhat has a faster lookup, vector or hashmap?
18:10slashus2dreish: As they are subject to change?
18:11dreishSTM is still a research topic, so I think he wants to reserve the right to throw out the entire current design and replace it with something else, preserving only the documented behavior.
18:11slashus2dreish: I would only look at the code in curiosity, minding the abstractions.
18:11dreishslashus2: No harm there.
18:12dreishMec: I think they're nearly the same if you use keywords or integers as keys, but you could always try to benchmark them.
18:13slashus2Mec: I seem to remember that it was log32 for vectors
18:13Mecthen its identicle
18:24slashus2So constant time for all practice purposes.
18:26durka42that's the idea
18:52hiredmanooo
19:07ieureAnyone have pointers to docs or examples for using zip-filter.xml?
19:55slashus2dreish: From the ant colony example, in the behave function, would ensure be useful instead of just dereferencing ahead when checking if an ant is ahead.
19:55dreishslashus2: I have to admit I've never read the ant colony code.
19:56slashus2I don't think it will be needed because on commit, it will check if an ant is ahead.
19:57slashus2When you use @reference without ensure inside of a conditional statement, you are saying, if this is the case on commit.
19:57dreishThis is to check before moving? If it uses alter(s) to actually do the move, ensure isn't needed.
19:57slashus2(and (pos? (:food @ahead)) (not (:home @ahead)) (not (:ant @ahead)))
19:58dreishNo, you're saying "if this was the case at the beginning of the transaction."
19:58slashus2alter isn't used inside of the agent function.
20:00slashus2but this check does happen inside of a transaction
20:28slashus2Is that not a valid use of ensure?
21:08Mecanyone have a nice fast prime sieve?
21:11gnuvince_The one in clojure.contrib?
21:11Mecblaspheme
21:12ieureSo, anyone have pointers on how to use zip-filter.xml?
21:12Mecwhere's it at in contrib? i dont see it
21:15sohailanyone here able to request me getting unbanned from ##java please :-)
21:17gnuvince_Mec: lazy_seq
21:39gnuvince_Excuse me, is a macro completely expanded at read-time?
21:40dnolenall macros are expanded before read as far as I can tell.
21:41dnolenactually it's seems weirder than that gnuvince
21:42dnolenfor example ^ and #' reader macros are evaluated before macro expansion
21:42gnuvince_So even if they have code like map or filter in them, they'll be executed and expanded completely at read time?
21:43dnolenyou can have pretty much anything you want in the expansion.
21:43gnuvince_So control is thrown back and forth between the reader and the evaluator?
21:44dnolenyou could have map and filter in the logic of the macro which creates the expansion, and in the expansion have macros, these will get expanded as well.
21:44Raynesgnuvince_: Macros are completely expanded in "Macro expansion" time according to Programming Clojure.
21:45hiredmanwhich is after read and before "evaluation"
21:45cmvkkhmm that's weird. wouldn't it be during read? it's not the reader that's expanding macros?
21:45cmvkk(i don't actually know)
21:45dnoleni note that [] and {} #{} are not part of the reader
21:45hiredman,(:macro (meta 'or))
21:45clojurebotnil
21:46hiredman,(macro (meta or))
21:46clojurebotjava.lang.Exception: Unable to resolve symbol: macro in this context
21:46dnolenthat is they don't become (vector ...) or (hash-map ...)
21:46hiredman,(:macro (meta or))
21:46clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/or
21:46hiredmanuser=> (read-string "(or a b)")
21:46hiredman(or a b)
21:48hiredmanuser=> (macroexpand '(or a b))
21:48hiredman(let* [or__3240__auto__ a] (clojure.core/if or__3240__auto__ or__3240__auto__ (clojure.core/or b)))
21:48hiredmanso obviously it is not expanded at read time
21:48cmvkkoh right. it's expanded at 'compile time' though.
21:48cmvkk...right?
21:49hiredmanthat apears to make sense
21:52RaynesThe Clojure google group has 1677 members!
21:53RaynesThere was only like a few hundred when I first looked at the group o.o
21:54gnuvince_What happens if I have side effects in my macro?
21:54gnuvince_Better to avoid those?
21:55cmvkkthey will occur at compile time
21:55Raynesgnuvince_: Depending on the side effects, you could kill your kitten, eat your babies, or implode the univurse :)
21:55cmvkkdemons might fly out of your nose
21:55gnuvince_Yeah
21:55gnuvince_That'll never work
21:56gnuvince_Fuck I'm tired of hunting this performance problem
21:58RaynesFor some reason, the Clojure plugin seems to interact with, and cause the Scala Netbeans plugin to throw an exception, but still work when a project is created.
21:58RaynesDoes anyone else here have both of these plugins installed and can confirm this for me?
22:19duderdoAnyone here running debian 5.0 with clojure?
22:28Mechow come it's every? but some
22:31hiredman,(every? identity [nil 1 nil])
22:31clojurebotnil
22:32hiredman,(some identity [nil 1 nil])
22:32clojurebot1
22:32Meci mean instead of some?
22:32hiredman,(every? identity [1 1 1])
22:32clojurebottrue
22:32hiredmansome returns the result of the predicate, not true/nil
22:33danlarkin? goes on the end of functions when they return a boolean
22:33hiredmanthe first non-nil(non false?) result of the predicate
22:33Mecwhy doesnt every just return the last value if all the previous are true?
22:36Mecmeh not really important i guess
22:37mattreplMec: have an example? I think you're missing that every? returns either a single true or false after testing the predicate function on every element of the collection
22:38slashus2Does anyone have any input on my previous observation?
22:39Meci was just wondering what the benefit is of having some return (pred x) instead of just true/nil
22:40Mecif it returned x the first time (pred x) was true, then i could see it working has a (first (filter))
22:41gnuvince_I'm sure this is asked often, but is there a way to force a macro to evaluate a symbol and not just take it as is?
22:41hiredmanthat is what unquote is for
22:42hiredman'~"
22:42hiredman'~'
22:42gnuvince_I meant at the call site
22:42gnuvince_(my-macro my-var)
22:42slashus2Whether or not to use ensure in the case of the ant colony simulation where you are checking if an ant is in the position you are moving to. Currently, in the behave function, it is just a deref inside of a transaction.
22:42gnuvince_and that my-var be expanded to whatever it is that's in it
22:43hiredmangnuvince_: so actually you want a function
22:43hiredmanbut, yeah, that is what unquote is for
22:43gnuvince_hiredman: I wanted a function, but this performance nightmare is forcing me to try every possible avenue
22:43mattreplgnuvince_: or eval
22:43gnuvince_(and the next one, is to just abandon the entire venture and switch to Haskell)
22:43cmvkkgnuvince_: the problem is that at compile-time, you don't necessarily know what the argument evaluates to.
22:44gnuvince_cmvkk: ah, right
22:44gnuvince_damn
22:45cmvkkis definline designed to solve that?
22:45hiredmanhave you tried definline?
22:45gnuvince_I haven't
22:47RaynesShoot. I keep typing a parenthesis before method calls in Scala.
22:47gnuvince_Does definline work?
22:47Raynes-_-
22:48hiredmanI've not tried it
22:48gnuvince_Can't get it to compile
22:51hiredmanas in AOT compile?
22:51gnuvince_Ah
22:51gnuvince_It must return a list
22:51hiredmanhow so?
22:51hiredman(definline f [x] x) works fine here if I call (f 1)
22:52cconstantinegiven two lists, is there an idiomatic way of combining them such that each element of the new list is every element of one list functioned to every element of the other list?
22:52gnuvince_(defninline foo [xs] `(something and such))
22:53durka42definline, not defninline
22:53hiredman(map #(% %2) list1 list2)
22:53gnuvince_durka42: whatever
22:53hiredmancconstantine: s/functioned/applied/
22:54cconstantinehiredman: oh.. thats what map does when given multiple lists? I thinking there is an x-y grid and I want to hit every spot
22:54hiredmangnuvince_: definline doesn't handle quoting like a macro, it is more link a function
22:55durka42cconstantine: map doesn't do that. given two lists it applies the function to the i-th element of both.
22:55hiredmanit just copies it's body inline whereever the function call happens
22:56cconstantinedurka42: is there a way to do what I want (without making my own function for it)?
22:56durka42,(for [x (range 3) y (range 3)] [x y])
22:56clojurebot([0 0] [0 1] [0 2] [1 0] [1 1] [1 2] [2 0] [2 1] [2 2])
22:56durka42is that what you want?
22:56hiredmanpffft
22:56cconstantinedurka42: I think then I can just... map my function to the resulting list?
22:57durka42well yeah, or put the function in there
22:57hiredman,(map vector (range 3) (range 3))
22:57clojurebot([0 0] [1 1] [2 2])
22:57durka42,(for [x (range 3) y (range 3)] (+ x y))
22:57clojurebot(0 1 2 1 2 3 2 3 4)
22:57hiredman~for
22:57clojurebotfor is not a loop
22:57hiredman~for
22:57clojurebotfor is a loop...in Java
22:57hiredmanugh
22:57cconstantinehehe
22:57hiredmanwho did that?
22:57hiredman~for
22:57clojurebotfor is a loop...in Java
22:57durka42well, neither is map
22:57hiredmanbah
22:58slashus2:-(
22:58durka42there is doseq, which is like for but really a loop
22:59gnuvince_definline isn't working
23:01cconstantine,(for [x (range 10 10) y (range 10 100)] (* x y))
23:01clojurebot()
23:01cconstantineis that a bug?
23:01cconstantineoh asdfasdfas nevermind
23:02cconstantine:)
23:02slashus2It behaves like nested loops.
23:02durka42,(range 10 10)
23:02clojurebot()
23:05slashus2durka42: Any idea about my ensure conundrum?
23:05durka42has it hit the logs yet?
23:05cmvkkis your problem just that you think it should be used in ants when it isn't?
23:06durka42oh wait, it is in my backscroll
23:06slashus2cmvkk: I don't know.
23:07slashus2maybe
23:07cmvkknot having read the ants program, isn't it that if you're checking to see if it's okay to move into a square, that you're then moving into it if it is okay?
23:07slashus2The dereference happens inside of a transaction.
23:07slashus2yes
23:07cmvkkright, but then don't you alter it in the same transaction?
23:07slashus2no
23:07cmvkkby actually moving into it?
23:07slashus2Wait.
23:07cmvkkso you just check to see if it's empty, then that's it?
23:08slashus2Let me confirm that.
23:08slashus2I think so.
23:08slashus2So in that case it is okay. As long as it is within the same transaction.
23:09cmvkkif you're altering a ref within a transaction, then you're basically ensuring it for that transaction.
23:09durka42so if you read and then later write, and it has changed in between, you retry?
23:09cmvkkthat ought to be the case.
23:09cmvkkwhen you enter a dosync, you're grabbing a snapshot in time of all the refs you touch.
23:10cmvkk(i think)
23:10slashus2Move is called inside of the transaction, which does alter.
23:10slashus2For some reason I didn't see that.
23:11slashus2I understand. I am still getting a grip on the transactions on variables thing.
23:48hiredman,(into {} [:a :b])
23:48clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword
23:49hiredman,(into {} [[:a :b]])
23:49clojurebot{:a :b}
23:49hiredmanexcellent
23:49cmvkkyou know it would be better if commas, instead of spaces, were just nothing.
23:49cmvkkthat way you could use them in numbers.
23:49cmvkklike 3,000,000 which doesn't work
23:50Mecis there a better way to do this: (every? identity (map somef coll1 coll2))
23:51durka42is that the same as (every? somef coll1 coll2)
23:51Meci dont think every takes more than one coll
23:51cmvkkno, it's doing the map then checking to see if there's any nils
23:51Mecideally i'd like to do what durka suggested
23:52cmvkkahh, i see now
23:52Mectho i guess since map is lazy it will still only take 1 pass not 2
23:53durka42correct
23:53durka42(i think)
23:54Mecyup so other then being verbose there's no problem
23:55durka42(every? (partial apply somef) (map vector coll1 coll2))
23:55durka42that's worse
23:56Meci dont think that would work
23:56durka42,((partial apply +) [1 2])
23:56clojurebot3
23:57Mecoh i see