#clojure logs

2011-07-13

01:21chrissbxHm, how would you write this Scheme code in clojure?: (letrec ((a (lambda (x) ... b ..)) (b (lambda (x) ... a ..))) ...)
01:22chrissbxI guess (defn ) in a local scope?
01:22amalloy&(doc letfn)
01:22sexpbot⟹ "Macro ([fnspecs & body]); Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body. fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
01:23chrissbxah ok. Thanks for your help, amalloy!
01:23amalloybut clojure's letfn only allows functions: you can't do a letrec with mingled functions/values
01:24chrissbxYeah, I feared that already.
01:24chrissbxWill have to do dependency analysis, I guess.
01:24chrissbxHm. Or why not just using (defn ) (def ) (defn ) in a local scope?
01:24amalloyum because that's wrong
01:25amalloyit pollutes the scope with global vars, and isn't threadsafe, and any number of other problems
01:27chrissbxSomething like: (defn locl [] (defn f [x] (g x)) (def x 1000) (defn g [y] (f (+ x y))) f)
01:27chrissbxexcept that this gives me "unable to resolve g"
01:27chrissbxThose aren't global vars, or are they??
01:29chrissbx&(defn locl [] (defn f [x] x) (def x 1000) (defn g [y] (f (+ x y))) g)
01:29sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
01:30chrissbxwhatever, then: ((locl) 10)
01:30amalloyyes, they are
01:30chrissbxugh
01:30chrissbxI'm not going to complain.
01:31amalloyvars are always global
01:31amalloy(except when they're not, see with-local-vars)
01:31amalloy(that doesn't solve your current problem)
01:31chrissbxehr, what are those introduced by let ?
01:31amalloylocals. bindings, whatever
01:31chrissbxhm alright.
01:31amalloybut a var is specifically things of class ##(class #'inc)
01:31sexpbot⟹ clojure.lang.Var
01:32chrissbxSo, using letfn is the only way to go, I guess? And doing dependency analysis myself.
01:33chrissbxGoing to save that for tomorrow.
01:33amalloyyeah, though tbh i don't know how scheme's letrec resolves the issue
01:33chrissbxUsually a dependency analysis, too.
01:34chrissbxAt least that's what some systems do; will have to read the spec for whether that's strictly necessary.
01:38chrissbxWell, R5RS says it's an error to expect to be able to refer to other variables from expressions other than functions.
01:38chrissbxBut some systems implement it.
01:39amalloychrissbx: you're writing it in scheme, you said?
01:39chrissbxYe
01:39chrissbxs
01:39chrissbxBut I'm not in the mood to cannibalize the system I'm using to do the analysis.
01:39amalloyif you wrote it in clojure you could use it as an embedded scheme interpreter
01:40amalloyie, (defn x [] (scheme (letrec ...)))
01:41chrissbxWell.. I guess you mean to say, once I've solved the letrec conversion issue.
01:41amalloywell, i wasn't addressing letrec specifically. bad example
01:42amalloyjust that if you write it in scheme, it has to be some external preprocessor you run on scheme files
01:42amalloyif you write it in clojure, you can intermingle the two
01:42chrissbxMaybe my converter will be able to convert itself. Right now I'm not interested in that capability.
01:43amalloyi don't understand. what capability are you interested in, then? automatically porting whole scheme apps?
01:43chrissbxYes
01:43chrissbxWell, and learning Clojure.
01:44amalloyit seems so unlikely any non-toy will ever convert totally automatically, and you would probably learn more clojure by writing in it
01:45chrissbxOk, and learning how to translate from Scheme to Clojure.
01:45chrissbxincluding learning how to write such a translator.
02:22amalloyhah, i like the "resolution" to the "build tool for clojure/java" thread. guys, shut up, go cure cancer
04:06pyrhi, can deconstruction be applied in binding ?
04:07pyri.e: (binding [[*sym-a* *sym-b*] (get-vector)] (do-something-else))
04:08ihodesdid you test it out?
04:08pyrin a large namespace, i'll test it out on the repl right now
04:09pyryeah, doesen't work
04:09ihodesyeah i just tried it too. never had before.
04:09ihodeswhat are you trying to do?
04:10pyrso since it doesn't work and the documentation for binding mentions that bindings are made in parallel (unlike let)
04:10pyrwhat's the idiomatic way of having one dyn declaration depend on another
04:11pyraccomplishing the same as: (let [first-sym (create-something) second-sym (do-something-with first-sym)] ...)
04:11ihodesbut affecting the global scope?
04:11pyrsame than that but with binding
04:11pyri could of course nest bindings
04:11pyrbut that's ugly, maybe it's the only way
04:12ihodeswhy not use some other reference? seems like vars might not be the way to go
04:13pyri have a macro that executes within the context of a connection
04:13pyrwell, ok, I see what your saying, I have a good workaround
04:14ihodesgood luck ;) sounds like a mess
04:18pyrihodes: not that much :) but talking about it helped, as often
04:19ihodespyr: good :) glad to be a cathartic outlet
05:40kumarshantanupyr: (binding [foo (get-foo) bar (get-bar)] (do-something foo bar))
05:41kumarshantanudoesn't that work?
05:43pyrkumarshantanu: yes, of course
05:43pyrthat's not what i was meaning to do
05:43kumarshantanuokay
06:43shtutgartHow can I cast class in clojure? (need it for interop)
06:49shtutgartAh, I can just provide type hint
06:58clgvshtutgart: you cant cast objects to classes in clojure but you can provide type hints that enable the compiler to omit reflection
07:03hiredmanyou can cast
07:03hiredman,(doc cast)
07:06shtutgartcast just throws exception if type of the object is wrong
07:07hiredmanshtutgart: then it is wrong
07:08hiredmanare you sure you want to cast?
07:08hiredmanthe jvm is stronglly typed, so you can't just cast things willy nilly
07:10zakwilson,(cast Double 1)
07:10clojurebotjava.lang.ClassCastException
07:11zakwilsonThis is unexpected though:
07:11shtutgartI have class A and need to call java method which requires class B which is a subclass of A; in such case I have to provide type hint
07:11zakwilson,(cast Number 1)
07:11clojurebot1
07:11zakwilson(isa? Number 1)
07:11zakwilson,(isa? Number 1)
07:11clojurebotfalse
07:11hiredman,(isa? Number (class 1))
07:11clojurebotfalse
07:12hiredmangah
07:12hiredman,(isa? (class 1) Number)
07:12clojurebottrue
07:12shtutgarthm, or not...
07:12hiredmanshtutgart: I would double check th type of the object
07:12zakwilsonOh, I had it backwards.
07:13hiredmanmakes isa? a pain in condp
08:05Scriptoris clj-http still the recommended http client for clojure?
08:22clgvwhen reading from a file with ObjectInputStream where I serialized clojure data with ObjectOutputStream I get the following exception: "java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.io.ObjectStreamClass" - does someone has an idea what the reason might be?
09:03kumarshantanuclgv: any example how are you using it?
09:04clgvkumarshantanu: yeah I can copy it for you
09:04clgvit's pretty straightforward
09:07clgvkumarshantanu: http://pastebin.com/Gc7S2PQU
09:07kumarshantanu,(let [byt (java.io.ByteArrayOutputStream.) out (java.io.ObjectOutputStream. byt)] (.writeObject out [1 2 3 4]) (println (str byt)))
09:07clojurebot��
09:08clgvkumarshantanu: I already worked around the header issue when appending. it works in some manual cases for multiple appending as intended.
09:12kumarshantanuclgv: what objects are you storing inside the vector before writing to the stream? (i.e. data-map)
09:12kumarshantanuI guess they need to implement the marker interface as well?
09:13kumarshantanuSerializable
09:13clgvkumarshantanu: only standard clojure datastructures and one deftype that implements Serializable
09:14kumarshantanuclgv: does it work when you omit the deftype object from the vector?
09:15clgvfor one data-map it works with it. I can try it in general without it
09:20kumarshantanuclgv: maybe you try writing the deftype instance to an ObjectOutputStream separately to see if it's the deftype that causing the problem
09:20kumarshantanuand implement Externalizable if required
09:20clgvkumarshantanu: thats an additional option. I thought about Externalizable as well a few minutes ago.
09:21clgvit's annoying that the serialization implementation has noch real means for debugging
09:22clgvok I omitted deftype and it still happens when I store two objects.
09:23clgvit's always the: "java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.io.ObjectStreamClass"
09:25kumarshantanuhmm, that's an array that can't be written to the stream -- obvious
09:25kumarshantanucan you convert the array into a vector before writing?
09:26kumarshantanuclgv: i suspect you will need to isolate the cases where serialization is breaking, an convert them under Serializable by some means
09:26clgvuhmm that exception is thrown during reading via ObjectInpuStream
09:26kumarshantanus/an convert/and convert/
09:26sexpbot<kumarshantanu> clgv: i suspect you will need to isolate the cases where serialization is breaking, and convert them under Serializable by some means
09:27clgvI have only one case with a native array and this is a double array
09:27clgvwriting the data to file does not throw any exception at all
09:28kumarshantanuArrays get created as the java.lang.Array class, which doesn't implement Serializable
09:28kumarshantanuit can be read as primitive data nevertheless (just speculating here)
09:29kumarshantanuclgv: is that (array) what is causing the issue while reading back?
09:30kumarshantanuclgv: maybe if you can try converting the array into a vector before writing...should that help while reading back?
09:30clgvkumarshantanu: if I write one instance of data-map everything works well. it only happens when I actually append something
09:30joegalloummmm... i'm not sure about some of that -- java arrays are not java.lang.Array (iirc there is no such class), and they are serializable.
09:31kumarshantanu,(type (into-array String "foo" "bar"))
09:31clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$into-array
09:31kumarshantanu(type (into-array String ["foo" "bar"]))
09:32kumarshantanu,(type (into-array String "foo" "bar"))
09:32clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$into-array
09:32kumarshantanu,(type (into-array String ["foo" "bar"])) ;; at last
09:32clojurebot[Ljava.lang.String;
09:33kumarshantanu,(.getComponentType (class (into-array String ["foo" "bar"])))
09:33clojurebotjava.lang.String
09:34kumarshantanuclgv: true -- i mixed up something earlier i guess
09:35joegallo,(instance? java.io.Serializable (into-array ["a" "b"]))
09:35clojurebottrue
09:35kumarshantanu,(supers (class (into-array [])))
09:35clojurebot#{java.io.Serializable java.lang.Cloneable java.lang.Object}
09:36clgvkumarshantanu: as far as I understand that know the ObjectInputStream is somehow expecting this ObjectStreamClass but finds actual data
09:36clgv*now
09:38kumarshantanuclgv: can you use reflection to see if the deftype includes a static variable called serialVersionUID ?
09:38clgvkumarshantanu: there is currently no deftype in the data anymore
09:39kumarshantanuObjectStreamClass seems to be required when reading objects back -- uses serialVersionUID to determine which version
09:39kumarshantanuclgv: okay
09:39clgvone stacktrace: http://pastebin.com/aDvxNNZj
09:40xianIs it possible to get the function which is defined (via letfn) locally by its symbolic name?
09:45kumarshantanuclgv: I can write an array and read it back
09:45kumarshantanu,(let [bos (java.io.ByteArrayOutputStream.) out (java.io.ObjectOutputStream. bos)] (.writeObject out (into-array [1 2 3 4])) (let [b (.toByteArray bos) bin (java.io.ByteArrayInputStream. b) in (java.io.ObjectInputStream. bin) ext (.readObject in)] (clojure.pprint/pprint ext)))
09:45clojurebot[1, 2, 3, 4]
09:46clgvkumarshantanu: yes. I tested this before. also works for vectors hashmaps list and most cases
09:46clgvs/and/in/
09:46sexpbot<clgv> kumarshantanu: yes. I tested this before. also works for vectors hashmaps list in most cases
09:49clgvkumarshantanu: ok I am now narrowing down the part of the data that causes the problem
09:50kumarshantanuclgv: okay, that's what i was thinking -- about narrowing it down to a small test case
10:06clgvclosing in...
10:09clgvkumarshantanu: it is indeed the 2d double array and therefor in the case before the deftype that was wrapping it
10:11kumarshantanuclgv: ah okay
10:11clgvI am trying to get the same error with a minimal data-map now
10:13kumarshantanucan we create 2D arrays in Clojure?
10:14shtutgart,(make-array int 10 10)
10:14clojurebotjava.lang.ClassCastException: clojure.core$int cannot be cast to java.lang.Class
10:15clgvyeah like that as well ##(repeatedly 3 (repeatedly 3 rand))
10:15sexpbotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
10:15clgvyeah like that as well ##(repeatedly 3 #(repeatedly 3 rand))
10:15sexpbot⟹ ((0.684066312440444 0.525795787150419 0.09663251276834983) (0.2233101514830721 0.18808849843110942 0.48354204576108295) (0.6133362272999827 0.30182543239240256 0.32658591964711126))
10:16clgvups missing the conversion^^
10:16clgvhere it is: ##(into-array (map into-array (repeatedly 10 #(repeatedly 10 rand))))
10:16sexpbot⟹ #<Double[][] [[Ljava.lang.Double;@166eac1>
10:16shtutgart(to-array-2d (repeatedly 3 #(repeatedly 3 rand-int))
10:17clgvkumarshantanu: but writing those arrays in there works pretty well in the minimal examples :(
10:17shtutgartthen ##(to-array-2d (repeatedly 3 #(repeatedly 3 (partial rand-int 10))))
10:17sexpbot⟹ #<Object[][] [[Ljava.lang.Object;@17c2535>
10:17kumarshantanu,(let [bos (java.io.ByteArrayOutputStream.) out (java.io.ObjectOutputStream. bos)] (.writeObject out (make-array Double 2 2)) (let [b (.toByteArray bos) bin (java.io.ByteArrayInputStream. b) in (java.io.ObjectInputStream. bin) ext (.readObject in)] (clojure.pprint/pprint ext)))
10:17clojurebot[[nil, nil], [nil, nil]]
10:20kumarshantanuclgv: can you print the data to see what it is before serialization, so that you can use the same data in the test?
10:23parasebaI'm having problems with leiningen 1.6.1 on clojure 1.3.0-beta1. Can't run tests inside an interactive session, I get IOException Stream closed
10:23parasebaanyone else having this problem?
10:23parasebacant call run task inside interactive either, same error
10:24clgvkumarshantanu: it's a 120x120 double array
10:28clgvkumarshantanu: if I convert it to a vector of vector that works. but it takes twice as much space.
10:36clgvthe hierarchy is: map -> map -> vector -> map -> array
10:38kumarshantanuclgv: i created a test project -- git@github.com:kumarshantanu/serial-test.git
10:38kumarshantanumaybe you can add the 2D double data to Data.java if you like
10:43clgvkumarshantanu: ok. just let me finish the Externalizable approach
10:47clgvclgv: I think you can just create a 2d array with random double values.
10:48clgvwith 120x120 entries.
10:51kumarshantanuclgv: "lein test" is passing with 3x3 2D double array
10:51kumarshantanui will try to put in more data there
10:58clgvit's really stupid that I can serialize something that cant be deserialized... :/
10:58clgvI would want it to fail on writing, if it cannot handle the array.
11:00kumarshantanuclgv: i added a random 2D double array data...it seems to work
11:00kumarshantanupushed it
11:00kumarshantanupassing for 120x120 array
11:00clgvkumarshantanu: the problem is that it works in manual test as well... and everything is using the same functions
11:03Scriptorfrom the mailing list, anyone have any opinions on which would be more efficient? (cont...)
11:03Scriptor(reduce into [] (repeat n xs))
11:03Scriptor(apply concat (repeat n xs))
11:03Scriptorboth take a vector, repeat, and flatten
11:03clgvkumarshantanu: I managed to save my deftype via externalizable in some simple examples
11:05symboleScriptor: You can look at the source of each. Are you trying to do some optimization, or just curious?
11:06Scriptorsymbole: someone asked how to do it in the mailing list, so just curious about whether mine is better or worse :)
11:06clgv kumarshantanu: but embedded in map->map->vector->map->deftype it does not work...
11:07Scriptoron first glance concat does seem to have a lot more overhead
11:08symboleWhy?
11:08clojurebotwhy not?
11:08symboleDamn, clojure.org is down again?
11:09symboleNevermind.
11:10clgvsymbole: clojure.org is up and running
11:10clgvScriptor: concat doesnt really do anything when it's calles since it's lazy
11:12Scriptorclgv: sure, but neither does reduce
11:12clgvScriptor: reduce is not lazy as far as I know
11:12dnolenScriptor: reduce is eager
11:13Scriptoroh, damn, I could've sworn it was lazy-seq'd
11:13Scriptorthanks for the clear-up guys!
11:14symboleLaziness doesn't say much about efficiency though.
11:14parasebaScriptor: reduce _needs_ to do something, since it has to return something, is not like concat that can return a lazy-seq
11:16Scriptorparaseba: true, it doesn't know what type the accumulator will be so it can't guarantee that it's something you could lazy-seq, forgot about that bit
11:18parasebaScriptor: it doesn't have nothing to "show" you before the whole seq is iterated
11:21clgvkumarshantanu: I have uploaded the data for you here: http://www.megafileupload.com/en/file/319690/bla-txt.html
11:21clgvkumarshantanu: it contains vectors instead of the arrays - but you can convert them easily
11:29Scriptorah, forgot that concat always returns a list, you'd have to call vec on my solution if you want it in vector form
11:29Scriptorinto uses conj so you get whatever type you pass
11:36clgvkumarshantanu: there seems to be a definite serialization error due to the hierarchie - but I dont know what causes it
11:44clgvkumarshantanu: I work around it by using the deftype that represents a compressed object at top level as well. this way it works
11:51dnolenanybody here use org-babel w/ Clojure much?
11:55clgvdnole: what is org-babel?
11:55clgvdnolen ^^
11:55dnolenclgv: http://orgmode.org/worg/org-contrib/babel/
11:56dnolenclgv: org-mode is one of the fancier Emacs apps, org-babel seems like a pretty interesting way to do literate programming.
11:57clgvdnolen: ok, emacs internas are greek to me ;)
11:58hugoddnolen: I use it
11:58dnolenhugod: thoughts? tips?
11:58hugodI had to hack it to get it to use an existing repl, I seem to remember
12:00dnolenhugod: do you actually code your libs with it?
12:00hugoddnolen: I use it for pallet documentation - after the fact
12:02dnolenhugod: interesting, seems like it allows you to document your code in a deep way while making it easy to extract the actual source.
12:03clgvprovided I use leiningen - what is the easiest way to get the version number that is defined in my project.clj when running my standalone.jar?
12:03hugoddnolen: it's useful to check that the documentation examples actually run
12:03technomancydnolen: someone did a crazy rewrite of the starter kit using babel
12:04technomancyI can't say I like the way org intersperses code and prose; cosmetically it just rubs me the wrong way
12:04scgilardiwe've decided that should be ugly
12:05technomancy#+begin_src ; eww
12:05technomancyscgilardi: hehe
12:05technomancyscgilardi: is that a reference to the lack of def-?
12:05scgilardibusted!
12:15dnolentechnomancy: is that so different from heavily documented code?
12:18Scriptorthere's the whole literate code movement
12:23devnDoes swank-clojure 1.3.2 work with clojure 1.3.0-beta1
12:23devnIt's broken for me...
12:23technomancydnolen: maybe if I had it set up to font-lock right it would sit better with me
12:23technomancydevn: I don't know. sounds believeable
12:23devnyay, technomancy is here.
12:24dnolentechnomancy: (setq org-src-fontify-natively t) ;)
12:24devnannddd, I'm an idiot: I had another swank session started
12:29hugodtechnomancy: I got the lein style checkouts working from a maven plugin :)
12:33technomancyhugod: handy!
12:34hugodjust need maven 3.0.4 to have it work with maven projects in the checkouts (as well as lein projects)
12:35lightningzephyrIs it just me, or if I don't upgrade lein every time I begin a new clojure project, I have dependency failures when I try to build?
12:36lightningzephyrBecause, you know
12:36lightningzephyrThat's kind of silly
12:42technomancyold versions of lein referenced build.clojure.org as a maven repo, which clojure/core has deprecated
12:42lightningzephyrAh
12:42lightningzephyrI saw a thing on the internet
12:43lightningzephyrAbout a survey from people about their experiences with clojure
12:43lightningzephyrIt was... illuminating
12:44lightningzephyrI was unaware there was a IRC room, for instance :)
12:44lightningzephyrKind of helps when it seems most example code online stopped actually working a while ago
12:45technomancyman if you judged clojure by the mailing list, you would really be missing out
12:45technomancyand yeah, rule 1 of clojure is don't trust blog posts
12:45technomancyactually there's already a rule 1
12:45technomancyrule 2
12:45technomancyclojurebot: rule 2 is don't trust blog posts.
12:45clojurebotIn Ordnung
12:45lightningzephyrlol
12:45technomancyclojurebot: rule one
12:45clojurebotrule one is if your answer to "how should I represent X" is "something that doesn't implement clojure.lang.IFn" then you are probably wrong.
12:46lightningzephyrLOL
12:46lightningzephyrbest bot
12:46lightningzephyralso, technomancy -- that rings many bells
12:46lightningzephyrSurely I've seen that name attached to clojure related things?
12:46hugodtechnomancy that reminds me - were you referring to stevedore script functions?
12:51technomancyhugod: not really, just chiding the author of that pragprog article for using the term "dsl" when he meant "compiler"
12:53hugodit's true though that the exception you get on invocation errors for script functions could be a little more helpful
13:28voltonHi, how do I get Clojure to work nicely with swank and slime?
13:28voltonIn Emacs I should say
13:29voltonI tried clojure-jack-in but all I got was: Copying 1 file to /Users/philipp/Desktop/Lisp/Firehose/lib
13:29voltonuser=> Connection opened on local port 61889
13:29volton#<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=61889]>
13:30technomancyvolton: you have an old version of swank-clojure installed somewhere (either in lib/dev via project.clj or in ~/.lein/plugins)
13:35voltontechnomancy: I deleted .lein and installed leiningen again
13:35voltonNow I get the following in *Messages*: error in process filter: eval-buffer: Symbol's function definition is void: define-slime-contrib
13:35voltonerror in process filter: Symbol's function definition is void: define-slime-contrib
13:42technomancyvolton: my guess is you have an incompatible version of slime installed somewhere
13:42voltontechnomancy: I installed it with quicklisp, was that a bad idea?
13:43technomancyI don't know; isn't quicklisp for handling CL libs?
13:44technomancyswank-clojure is only compatible with a single version of slime, probably not the one that CL wants to use
13:46voltontechnomancy: yes, I am trying to get CL and Clojure play along nicely. My version of slime is slime-20110619-cvs
13:47technomancysorry, I don't know how to make that work.
13:48voltontechnomancy: why is swank-clojure dependent on one specific version of slime?
13:49technomancyvolton: because slime breaks all the time, and I don't have the time or motivation to follow it closely
13:49voltontechnomancy: I see, that sounds reasonable ;-)
13:49technomancyalso because slime devs refuse to release stable versions; they just expect people to follow CVS for everything
13:49jcromartiewhat's the best way to name fns that use side effects to retrieve data, like from a database? should it be "get-..." ?
13:51voltontechnomancy: thank you, in this case I guess I will stick with the Netbeans plugin
13:51voltonIf only Maven would finish downloading the internet...
13:52technomancyit seems most people lose interest in CL once they learn clojure, so it hasn't proven to be much of a problem in practice
13:52amalloyjcromartie: i prefer fetch
13:52amalloyjava has polluted "get"
13:53amalloyor read
13:53voltontechnomancy: you are right, I could just set my inferior lisp to lein repl and use that
13:54jcromartieamalloy: true
13:57voltonI hope this is not a dumb question but is there an advantage to learning clisp instead of clojure?
13:57Scriptorvolton: so the advantages of common lisp over clojure?
13:58voltonScriptor: yes
13:58amalloyuhhhmmm. i guess the advantage is "if you are the sort of person who will prefer knowing clisp to knowing clojure, you should learn clisp"
13:58Scriptornot a dumb question, just a huge question :p
13:58technomancyCL has better support for VAX filesystems
13:59amalloyCL's certainly got a more thorough reference manual
13:59Scriptorit's probably easier to quickly google for CL stuff
13:59Scriptoralthough clojuredocs.org helps
14:00amalloyScriptor: not sure about that one really
14:00amalloyclojure is a pretty unique word to put in a search; "common" and "lisp" could mislead google
14:00symboleCL doesn't require a VM.
14:01amalloys/require/get to use
14:01Scriptoramalloy: true, but more often than not every time I search the initial result is just clojure.org/libraries, clojure.org/datatypes, etc.
14:01amalloy(but yes, it's an advantage in some ways)
14:01amalloyfair point
14:02technomancyif you time-travel back to the 1980s, your CL knowledge will still be useful. clojure, not so much.
14:02Scriptorvolton: you'd have proper TCO
14:02symboleCL has better tools.
14:03technomancyScriptor: depends on the implementation. it's not required in the spec.
14:03Scriptortechnomancy: clisp has it though, right?
14:03technomancyoh, dunno
14:03technomancyI was under the impression it was rare
14:04sjlScriptor: I think you have to do something special to enable it
14:04Scriptorreally? I thought it was common, considering how often clojure's lack of it is brought up :)
14:04technomancyScriptor: it's the schemers that complain
14:04voltonScriptor: I have still not figured out if TCO is something that you actually need
14:04sjlScriptor: Yeah, (compile 'some-tail-recursive-function)
14:05voltonFrom a noobie standpoint, clojure has a more modern feel to it, when it comes to function names for example
14:06voltonmapcar is just called map for example (as far as I know)
14:06ScriptorI think some CLers complain that Clojure's "mini-languages" make it less uniform, though I disagree
14:07symboleScriptor: What mini-languages?
14:07Scriptorvolton: being that it's a lisp 1 clojure is a bit nicer to use for functional programming, if you're into that
14:07Scriptorsymbole: referring to this: http://blog.fogus.me/2010/03/23/clojures-mini-languages/
14:07voltonsymbole: http://blog.fogus.me/2010/03/23/clojures-mini-languages/ I guess
14:08volton:-P
14:08Scriptorah, the guy complaining is a schemer, not CL
14:08symboleCL has most of those too.
14:09voltonIs clojure's support for parallelism really better than CLs?
14:10technomancyvolton: CL's data structures are mutable by default, which is madness for parallelism
14:10technomancyBaker's equality paper makes this really clear
14:10technomancyclojurebot: equal rights for functional objects?
14:10clojurebotYour mock object is a joke; that object is mocking you. For needing it. -- rhickey
14:10symbolevolton: I think locking is the predominant model.
14:10technomancyclojurebot: come on man, this is basic stuff.
14:10clojurebotc'est bon!
14:11voltontechnomancy: found the paper, I will have a look at it
14:11technomancyclojurebot: Equal Rights for Functional Objects is Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://home.pipeline.com/~hbaker1/ObjectIdentity.html
14:11clojurebotAck. Ack.
14:12technomancyif you read that still want to pursue CL, more power to you; at least you'll know what you're getting into.
14:13voltontechnomancy: I think I will go with Clojure. I don't want to learn another language that requires locking for parallelism
14:17voltonThank you guys, you definitely helped me make my mind up!
14:18symbolevolton: You should go #lisp and ask them too.
14:20technomancysymbole: are you saying that #clojure may not be the #1 source for objective straight-up facts on which lisp dialect is the best? I'm shocked.
14:20technomancyI actually had a CLer in #emacs try to convince me that Scheme and Clojure were "not lisp dialects" simply because they weren't CL.
14:21technomancyit's always fun when you can shoot down an argument simply by linking to the wikipedia article for a given logical fallacy: http://en.wikipedia.org/wiki/No_true_Scotsman
14:22voltonThat's why I went here to ask, I'm a bit afraid of Lispers since I asked some questions in #emacs
14:23Hodapptechnomancy: That's not entirely a "No true Scotsman" fallacy unless it's got a particular context.
14:24technomancyhe linked to a naggum article that basically made that case.
14:24voltonI read a blog post by someone once arguing that there was no point learning clojure as its best feature would surely make their way into CL over the next 10-20 years
14:25Hodapptechnomancy: However, all of those things are definitely Lisps, they're just not Lisp. Or LISP. Or something like that.
14:26Hodapptechnomancy: If it resembled "No Lisp would have that property." "Scheme has that property." "No _true_ Lisp would have that property." then it'd certainly be that.
14:27technomancyhm; yeah. it was basically a very circular definition, but I don't know if it followed that redefinition-by-exclusion pattern.
14:27jweiss_clojure.contrib.trace/dotrace expects a literal list of fn's to trace. what if i want that list to be computed?
14:27jweiss_i think i'm hosed unless i write my own trace macro
14:28Hodapptechnomancy: Hurry up and say something stupid so I can make a pun about you not making a _true_ "no true scotsman" fallacy.
14:28technomancyHodapp: oh man that would be so awesome.
14:28technomancyI'm ashamed I didn't think of that myself
14:28Hodapplol
14:29pjstadigno _true_ logician would have done that
14:29Hodapp9_9
14:32voltonHere's the post I was referring to, it's depressing: http://axisofeval.blogspot.com/2010/04/why-i-ignore-clojure.html
14:34Hodapptl;dr HEY YOU KIDS GET OFF MY LAWN
14:35technomancyyeah, that is a naggum-level troll.
14:37HodappThey're... Lisp hipsters. Lispsters?
14:37Hodapp"I used Lisp before it was popular."
14:40symboleI think it's only lispers on the internets. I've met real life lispers who has nothing but good things to say about Clojure.
14:40jcromartieLispsters... oh no
14:40jcromartieI interviewed a guy who said "oh yeah, Lisp, that is probably my least favorite language... all the parentheses"
14:40Hodappbleah, I hear that a lot
14:41jcromartieI had to show him paredit-mode
14:41Hodappalong with "I hate Python, whitespace indentation sucks"
14:41jcromartiehe was a MS in CS
14:41Hodappand a first-year CS student who hated Python because it was "too easy"
14:41jcromartiehah
14:41jcromartietoo easy... go use Malbolg
14:41jcromartie*e
14:41Hodappand he said that C++ was "pretty easy" and "pretty much the same as assembly"
14:42jcromartieI will accept "C is basically portable assembly language"
14:43jcromartiebut C++... not so much
14:43HodappC++ is a clusterfuck that needs to be taken out back behind the shed and shot.
14:43HodappC, I am okay with.
14:43HodappThe problem that I always hit is how many people think that C++ is simultaneously C and $higher_level_language
14:44jcromartieis there an idiomatic way to get a hash-map with only certain keys in it?
14:44Hodappwhen really it sucks very badly at being either
14:44jcromartieI already have (into {} (filter (comp keys key) m))
14:44mefestojcromartie: i think select-keys ?
14:45jcromartie,(let [f (fn [keys m] (into {} (filter (comp keys key) m)))] (f {:x 1 :y 2 :z 3} #{:x :y}))
14:45mefesto,(doc select-keys)
14:45clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
14:45clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
14:45jcromartieerp
14:45jcromartieah
14:45jcromartienice
14:45jcromartieI should use find-doc
14:46jcromartie(more often)
14:47jweiss_is there a non-roundabout way to get a ns-qualified symbol from a non-qualified one?
14:48jweiss_all i can see is converting to strings and then using (symbol ns name)
14:49mefesto,(resolve 'inc)
14:49clojurebot#'clojure.core/inc
14:49jweiss_mefesto: that is a var, not a symbol
14:49mefestoah
14:49jweiss_i don't know how to go from var->symbol either
14:49jweiss_just the other way
14:53amalloy(comp symbol name)?
14:53amalloyoh you're going the other way
14:53amalloy,(-> 'inc resolve meta :name)
14:53clojurebotinc
14:54mefesto,(let [x (resolve 'inc)] (symbol (str (.ns x)) (str (.sym x))))
14:54clojurebotclojure.core/inc
14:54mefestomeh :-\
14:55mefestonon-preferrable route :)
14:55amalloywhy do you want to do that, anyway?
14:56jweiss_amalloy: i'm trying to grab all the fn's in a namespace and pass them to clojure.contrib.trace/dotrace
14:56jweiss_but since it's macro, i have to wrap it in another macro
14:56amalloydotrace won't accept vars?
14:57jweiss_amalloy: hm... maybe it will
14:57jweiss_i'll try
14:57amalloydoesn't look like it, from the source
14:58jweiss_amalloy: yeah that is why i didn't try it before
14:59jweiss_yeah i get CCE
14:59jweiss_so no vars
14:59jweiss_boo
15:00mefestoany clojurians jump on google+ ?
15:01symboleJoin my "Clojure is not a Lisp" circle. 8-)
15:01jweiss_i'm on google+
15:02technomancyI was on g+ until I "upgraded" my apps account and it decided not to be available for my organization; woo!
15:18cemerickClojure isn't a lisp anymore?
15:18cemerickOh well, it was nice while it lasted.
15:22mefestofinally things at work quiet down enough that I can catch up on the mailing list and #clojure and today both are fairly quiet :)
15:48Dranikhi all!
15:48Dranikhow to use the ring's parameter :content-type to set utf8 encoding?
16:29benhurdoseq
16:29benhurdoseq
16:30chouserdoseq!
16:30chouserdo! seq!
16:31cemerickchouser: you just invented an Ook! dialect.
16:38jcromartiesee seq, see seq do, doseq do
16:54chouserheh
16:57jcromartieso I've got an itching to implement a multimethod-based interface for messy table queries in ClojureQL
16:57jcromartiesince our DB sucks
16:58AWizzArdWhat is algo.monads?
16:58jcromartielike, if I wanted to apply some restriction to a table without knowing which table it was and what columns it uses for the particular restriction
16:58jcromartielike, (limit-date foo "2011-07-01" "2011-07-10") might use different columns for different tables
16:59jcromartieseems like a good fit for the mutlimethod dispatch
16:59jcromartie(defmethod limit-date :tname)
16:59jcromartieerr
16:59jcromartiedefmulit
16:59jcromartieyou know
17:02AWizzArdWhat is algo.monads?
17:02AWizzArdhmm
17:04dnolenAWizzArd: probably Konrad Hinsen's monad library from contrib
17:16chrissbxWhat is iota called in Clojure again?
17:17amalloychrissbx: start with telling us what iota does in scheme :P
17:18chouserhm. maybe 'atom'?
17:18chrissbxhm well range seems to be it.
17:18chrissbxI think iota is standard in mathematics, which is why I omitted an explanation.
17:18amalloy$google iota math
17:18sexpbotFirst out of 33300 results is: Greek letters used in mathematics, science, and engineering ...
17:18sexpbothttp://en.wikipedia.org/wiki/Greek_letters_used_in_mathematics,_science,_and_engineering
17:18chouserhm, indeed. range.
17:19amalloychrissbx: afaict from wiki, that's only true in apl, not in other math contexts
17:28jonabbey,(doc when-not)
17:28clojurebot"([test & body]); Evaluates test. If logical false, evaluates body in an implicit do."
17:28chrissbxHm, I've seen it used in other contexts than APL and Scheme.
17:29chrissbxBut I'm not a mathematician; seems I've mis-concluded from having it seen relatively widely that it would come from there.
17:30chrissbxHaskell seems to prefer "range", too. "Range" seems a bit odd since (I think) that is defined in math also for reals (or maybe other stuff).
17:31chrissbxIn fact I've implemented a "range" datatype in Scheme exactly to specify ranges with min and max without need to itemize.
17:31Sushi_Not necessarily a clojure question, but does anyone know of chars that could go to stdout that would destroy the terminal buffer?
17:31Sushi_I'm spitting something out that keeps ruining the terminal output before it
17:32mefestoSushi_: maybe backspace characters? "\b" or maybe \backspace ?
17:32chrissbx(I implemented min and max or just min or just max, in fact)
17:33Sushi_mefesto, I'll look for those, thanks. It's weird because if I dump the output to a file it looks fine...
17:34chrissbxamalloy: http://en.wikipedia.org/wiki/Interval_(mathematics) seems closer to describe what "range" does. (Maybe hence the iota)
17:35chrissbxexcept that they default to real here.
17:35chrissbxMaybe a mathematician could enlight us.
17:35devnI'm a trained mathemagician.
17:43AWizzArddnolen: It seems it was just recently added to build.clojure.org
18:53mattmitchellIs it possible to get the parent namespace? The one that "uses" another?
18:57amalloyno such thing exists
19:04mattmitchellamalloy: Were you answering my ns question?
19:04amalloyyes
19:04mattmitchellamalloy: Ok thanks
19:51CozeyIs it possible to define a macro creating a (defun )
19:51Cozeyand then use this macro with ^:private, so the ^:private applies to the (defun ) ?
19:53cemerickCozey: if you just reuse the name provided by the user of the macro, then any metadata (including ^:private) will be carried along without you doing anything
19:53cemerickAnd, it's defn, not defun ;-)
19:53Cozeyoh yes. i just did some emacs lisp today :-)
19:54Cozeywhat do You mean by reuse?
19:55Cozeyoh ok! it's working
19:55Cozey:-)
19:55Cozeyhow is it working?
19:55Cozeybtw?
19:56Cozeyhow does clojure compiler knows how to apply this meta-annotation to the form returned ? (since the form could be anything)
19:56cemerickCozey: The metadata is on the symbol, which you're just carrying over from the macro invocation to the form you emit from it.
19:56Cozeymmhm
19:56Cozeyand it works for all kinds of def's?
19:56Cozeyor maybe in reality there is just one kind of def
19:57Cozeyothers being macros as well
19:57CozeyOh I love this language. why don't people already know it
20:00ChousukeCozey: that's right :P
20:00Chousukedef is all you need
20:00Chousuke,(macroexpand '(defn foo [x] (bar x)))
20:00clojurebotDENIED
20:00Chousukeoh right
20:00Chousukeblah
20:01CozeyI'll do that at home.
20:02Chousukeit just expands to a (def foo (fn ...)) :)
20:04cemerickCozey: this might help? https://gist.github.com/562cc9580b0579de8179
20:05amalloycemerick: flaunting your shiny new 1.3 features in front of us luddites. so cruel
20:06Cozeycemerick: ah.... I get it
20:07Cozeyso this meta is on lower level
20:07Cozeygood. I use 1.3 fortunately
20:13cemerickCozey: it'd work on 1.2 too; 1.3 just adds the ^:foo shortcut for ^{:foo true}
20:14Cozeymhm
20:16amalloycemerick: clojure is way behind the times, using minor versions. should follow chrome/ff and switch to version 22
20:16technomancymight as well skip to 25 so it's ahead of elisp.
20:17amalloytechnomancy: that would be so presumptuous. clojure isn't even a lisp
20:48pcavsamalloy: buhhh, whaaa? DId I miss something?
20:50amalloypcavs: (11:20:55 AM) technomancy: I actually had a CLer in #emacs try to convince me that Scheme and Clojure were "not lisp dialects" simply because they weren't CL.
20:50amalloythen a bunch more derision on that topic
20:51pcavsamalloy: oh boy...
20:52pcavsamalloy: technomancy: What's the story of GUILE replacing ELisp? My friend said that they had a reasonably working Emacs on GUILE
20:53pcavsthat would be swell, what would you do with continuations on emacs? You could use AMB!
20:53cemerickI thought #emacs was supposed to be reasonably reasonable?
20:53Scriptorevery channel has its bad apples
20:53pcavsoh, I have nothing against elisp, well besides the dynamic scope
20:54Scriptordoesn't the new version have lexical scope?
20:54pcavswell that'll screw up a whole bunch of elisp...
20:55pcavsI remember looking at the .el's and being shocked to see bindings that only existed to take call another function with that variable getting shadowed...everything being a global variable is kind of scary =\
21:05technomancylexical scope is opt-in for compatibility reasons
21:06technomancyyeah, #emacs is usually pretty decent, but there's a CLer in there with a chip on his shoulder
21:08technomancyhe also argued that mutable strings and vectors in CL weren't a problem because you can just audit all the libraries you use to make sure none of them contain any mutation.
21:20ssiderisso, and sorry for being so completely off-topic, who's buying a macbook air tomorrow
21:20ssiderisI'm trying really hard not to
21:20ssideris(if the rumours are true)
22:08cemericktechnomancy: any way to get lein to run javac before AOT-compiling Clojure?
22:09cemericks/before/after
22:09sexpbot<cemerick> technomancy: any way to get lein to run javac after AOT-compiling Clojure?
22:24Scriptordoes anyone know of a list of 4clojure answers?
22:25ScriptorI keep getting the nagging feeling that mine aren't idiomatic enough
22:31amalloyScriptor: youz has one on github
22:33amalloyhttps://github.com/youz/4clojure-golf but obviously he focuses on short solutions rather than pretty
22:34Scriptoramalloy: thanks
22:42ihodesScriptor: run by a gist/pastebin of a bunch in here
23:03technomancycemerick: it should happen if there's a :java-src key in project.clj
23:03technomancyoh, he left
23:43jamiltronI was wondering the same thing about 4clojure - I have many solutions, but several of them probably have much more Clojure-ish ways of doing them. Can I link a gist of one of the solutions to get some advice?
23:44amalloyjamiltron: knock yourself out
23:47jamiltronhttps://gist.github.com/1081904
23:54jamiltronI feel that sort of answer is more of a dirty form of Scheme than it is of Clojure.
23:55amalloyjamiltron: have to say that's pretty dreadful :)
23:55amalloyone thing you're missing is that clojure has vectors, which append to the end instead of consing to the front, so your tail-recursive solutions don't have to end with a reverse
23:57amalloyit also seems to me that you're basically reimplementing reduce, right? you consume exactly one element of n in every iteration, so you can use reduce to manage the "walk over the whole list" part of the problem
23:57jamiltronOh so have the "n" in pack-iter be a empty vector, and then instead of using cons use conj instead.
23:58jamiltrontoo many insteads
23:58amalloyright, basically
23:59amalloyif you'd like a hint on a really neat way of doing it, check out ##(doc partition-with)
23:59sexpbotjava.lang.Exception: Unable to resolve var: partition-with in this context
23:59amalloy&(doc partition-by)
23:59sexpbot⟹ "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions."
23:59jamiltronAh thanks