#clojure logs

2009-05-20

00:08duck1123_How come I can't negate thrown? within an is macro?
00:09duck1123_I wanted to simply verify that a certain exception wasn't thrown
00:44arohnerduck1123_: because "is" is a multimethod that dispatches on the first form passed to it
00:45arohnerI assume you'd like to do (is (not (thrown? ...)))
00:45arohneryou have a good use case. post a message to the group
01:33seangrovehey guys, wondering what the options are for automated testing before I dive into the clojure world?
01:41cadswhat converts :key into "key"?
01:41hiredman,(doc name)
01:41clojurebot"([x]); Returns the name String of a symbol or keyword."
01:42cads'doh I ought to know that
01:44arohnerseangrove: there is test-is in clojure-contrib
01:46seangrovearohner: have you worked with it much?
01:46arohneryeah. It's running as we speak :-)
01:46arohnerit's your standard test framework
01:46arohneroh, there's also fact
01:47seangroveah, cool
01:47arohnerhttp://github.com/weavejester/fact/tree/master
01:47arohnerit's kind of like haskell's quickcheck, if you're familiar with that
01:47seangrovehaven't dabbled with clojure at all yet, just wanted to make sure that was covered before I get too far into it
01:47seangrovearohner: nah, I haven't done any heavy functional programming
01:48seangrovemainly just some mall scheme and CLOS projects
01:48cadsis there a function sym such that (apply #([% (class %)]) (sym "dog" 123 'cat :bat)) => [dog123catbat clojure.lang.Symbol]
01:49hiredmanthat would not work
01:49hiredmanfor a number of reasons
01:49hiredman,(symbol "foo")
01:49clojurebotfoo
01:50cads,(symbol (str "rat" "cat" 123 "hellbat"))
01:50clojurebotratcat123hellbat
01:50replaca,(symbol (str :bat))
01:50clojurebot:bat
01:50cads,(symbol (str "rat" "cat" 123 (name :bong) "apple"))
01:50clojurebotratcat123bongapple
01:50hiredmana. (sym "dog" 123 'cat :bat) would try and call sym on the args "dog" 123 'cat :bat and there is no function named sym
01:51hiredmanb. your function literal there takes one arg
01:51replacahiredman: he as using sym as the free variable in his question
01:51replaca*as => was
01:51cadsI think I could write sym in 3 lines
01:51hiredmanwait
01:51hiredmanso you got "sym" but couldn't find "symbol" on the api page?
01:52replacajava-utils/as-str might help here
01:52replacahiredman: you're not understanding what he meant by "sym"
01:52replacareplace it with foo in his question
01:53replacais there a function "foo" such that ... (foo "dog" 123...)
01:53replaca?
01:54hiredmanreplaca: yes, and the function symbol is more or less what he was looking for
01:54cadshired man, I'm supposing a function named sym which operates like str on a variadic list of operands to let you concatenate a symbol name from a few components of different types.
01:55hiredman,((comp symbol (partial apply reduce str)) "dog" 123 'cat :bat)
01:55clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword
01:55cads,(name "str")
01:55clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Named
01:56cads,(symbol "te:st")
01:56clojurebotte:st
01:57cads,(defn sym [& glargs] (symbol (apply str glargs)) (sym "hyper" 'rat :cat)
01:57clojurebotEOF while reading
01:57cads,(defn sym [& glargs] (symbol (apply str glargs))) (sym "hyper" 'rat :cat)
01:57clojurebotDENIED
01:58cadshehe, it yiels hyperrat:cat
02:06replaca(defn catsym [& args] (symbol (apply str (map as-str args))))
02:06replacawhere as-str is defined in clojure.contrib.java-utils
02:07replaca(catsym "dog" 123 'cat :bat) => dog123catbat
02:08replacacads: I think that's what you're after, right?
02:09replaca~def as-str
02:09replaca~doc as-str
02:09clojurebotTitim gan �ir� ort.
02:09replacaoh well
02:34jdzas far as i can see there is no way to throw an exception with some data in it, right?
02:34replacajdz: well, you can, but you need to create your own exception class and gen-class it
02:35replacajdz: and then it will probably be wrapped
02:35jdzthat is what i want to avoid doing
02:35jdzbecause gen-class requires compilation
02:36jdzsomething akin to CL's throw/catch would be cool, and could be implemented using Java exceptions
02:36replacaI used a method in cl-format where I built error information lower down with a special function
02:37replacayou might also want to look at Chouser's error-kit in contrib
02:37jdzthat is actually what i need, non local transfer of control with some data passing
02:37jdzye, will look at error-kit, maybe there's something cool.
02:37replacain cl-format, I only wanted to be able to end up with a more sophisticated RuntimeException, so it may not be sufficient for you
02:38replacaI haven't tried error-kit yet, but I want to :-)
02:38replacabut I haven't written code that does anything but die on errors since Chouser wrote it
02:39jdzthere's a pretty hackish thing in contrib/except
02:39replacaoh, I haven't looked at that. I thought it was just cleaning up error messages
02:41replacalooking at contrib/except, it doesn't look like what you're after
02:41replacajust convenience wrappers
02:43jdzhmm, looking at error-kit it seems i can use proxy after all...
02:43jdzsomebody's really smart around here :)
02:44replacayeah, Chouser's spent a lot of time understanding how Clojure really works
02:45replacaare you looking at his proxy + IDeref trick?
02:45clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
02:45jdzye, the IDeref thing
02:46replacayeah, that's clever. I want to play with it, too
02:48replacatime for bed!
03:14cadsreplaca, that's it :)
03:15cads~def str
04:16opqdonutcan i somehow "store" a set of bindings that's in effect at some point, and eval something in that context later?
04:18opqdonutessentially, i have a macro that creates a datastructure with expressions inside it, and i want to be able to create a closure over that macro: "(defn [arg] (macro ... something using arg ...))"
04:18opqdonutthe expressions aren't evalled until much later, and arg won't be in scope then
04:20hoeckopqdonut: with "bindings", do you mean dynamic vars?
04:21hoeckopqdonut: or just values bound in a let-form?
04:27jdzopqdonut: macros are run at compile time; when your program executes, all macros have been substituted by corresponding code.
05:02opqdonuthoeck: let-form
05:14wnonga terrible beginner here (to clojure as well as IRC)
05:16wnongi am a the getting started with the prag-prog book and am getting error with jline/consoleRunner (NoClassDefFoundError)
05:23jdznever used that, so all i can suggest is to use the exact version of the software that is used in the book.
05:23wnongi have the same version from the book.
05:25wnongso far i have found ..googling that it is something to do with the absolute path (of jline.jar). I tried this too.
05:25Chousukeprobably misconfigured classpath
05:25Chousukeit's in the wrong directory
05:25Chousukethe jar that is
05:25wnongi have all the jars in the /lib directory
05:25wnongincluding the clojure.jar
05:26Chousukeand how do you run clojure?
05:27wnongi have been doing simple test runing the clojure.jar itself
05:27wnongbut now i am going by the book and trying to run the script (repl.sh)
05:27wnongand get this error "Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner"
05:28Chousukeprobably the repl.sh sets up the classpath wrong.
05:29Chousukelisppaste8: url
05:29lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
05:29Chousukepaste its contents there
05:29wnongok
05:31lisppaste8wnong pasted "prog-clojure-book-getting started" at http://paste.lisp.org/display/80539
05:31wnongdone
05:32Chousukeis htat CLOJURE_DIR path correct?
05:32Chousukedoes it contain your /lib?
05:32jdzand are the newlines really where they appear in the paste?
05:32wnongyes
05:32wnongyes
05:33wnongthere are 3 lines
05:33jdzthere is a space between : and classes
05:34wnongi fixed that now and same error
05:34jdzand $CLOJURE_JAR is not used, btw.
05:35Chousukejdz: that doesn't matter; it's in the classpath anyway
05:35jdzyes, i'm just saying
05:35jdzif it's not used, it should not be theer
05:35wnongyes, i was trying to modify it according the wiki-book
05:35jdzthere even
05:36Chousukedid you check if the lib dir actually contains jline-0.9.94.jar
05:36wnongI tried testing the jline itself going thru http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Linux
05:37wnongyes jline version is in the lib dir
05:38wnongfrom the link above, i was trying out : java -cp $CLOJURE_DIR/jline-VERSION.jar:$CLOJURE_JAR \ jline.ConsoleRunner clojure.lang.Repl
05:38Chousukeuh, VERSION?
05:38wnongofcourse replacing the version with my jar-name
05:38Chousukeright.
05:39Chousukeand it's the 0.9.94 version?
05:39yasonWhich sounds better: a ref containing a hash-map that contains other refs as values, or a ref containing just a hash-map with direct values and the whole hashmap is updated with update-in?
05:39wnongyes it is
05:39Chousukereally weird
05:39Chousukeensure that your CLOJURE_DIR has no typos
05:39yasonIn other words: is it ok to sow refs around like mad rather than use them sparingly?
05:39Chousukethat's the only thing I can think of anymore.
05:40wnongok..will check again. thx for ur time
05:41Chousukeyason: if you're using many Refs, you're most likely trying to emulate mutability somehow.
05:41Chousukeyason: the fewer refs you have, the less code you have to coordinate with dosync.
05:41yasonChousuke: I have a single hashmap that contains most of the mutable state of my program.
05:42hoeckyason: depends on your granularity needs
05:42Chousukea single ref for that is fine in many cases.
05:43yasonChousuke: it's a live database of stuff I need to update and read all the time. Currently I have one ref that is used to hold the whole hashmap
05:44Chousukeat the very least, you should avoid storing each database entry in a ref.
05:44yasonhoeck: That brought me to this question: I need to change the data in the hashmap's values quite often but the values themselves are rather independent of each other
05:44yasonhoeck: On the other hand, I need to read / filter values from the whole database at times, which would mean dereffing a lot of refs
05:45hoeckyason: maybe use atoms then for the hashmaps values?
05:45yasonChousuke: Ok, so refs can be considered expensive, complexity-wise?
05:45yasonhoeck: If they're lighter, yes. I haven't got much "feel" for the differences of refs and atoms yet
05:45Chousukewell, they're trickier than just having immutable data, that's for sure :)
05:46Chousukeatoms are just holders for data that are atomically swappable, with no coordination of how the changes happen.
05:46yasonChousuke: How would you handle long-running mutable data in Clojure anyway? I can write most of the functionality of my program with immutable data but I need to store stuff somewhere
05:47Chousukea ref is fine for that.
05:47tWiplong running? how long? perhaps you could consider a database
05:47Chousukeclojurebot has its entire database of definitions in a single map with a single ref.
05:47Chousukeit's not very high traffic though.
05:48Chousukebut adding to the map is cheap even if it grows big.
05:48yasontWip: days, weeks. A database would be ok if I could easily shove Clojure objects there
05:49tWipusing JDBC from Clojure is pretty easy
05:49yasontWip: isn't JDBC relational?
05:49tWipbut I think Clojure would also be good for prevalence type solutions, if you want to have everything in memory
05:49tWipyeah jdbc is for sql databases mostly
05:50Chousukeif you want more granularity, you could also divide your database maps
05:50cddrIn java, you can get at "this" during the constructor. Is that possible in a proxy?
05:51yasontWip: I'm more after object databases.
05:51Chousukeyason: make 4 maps (in 4 refs), then use some functions to transparently select which of the maps to write to when you add to the database; when you read, you can pretty easily combine the four maps
05:52tWipfor some value of "object" I guess...
05:52Chousukeyason: though, overwriting might be a problem :/
05:52Chousukehmm
05:52Chousukenah, a single map would probably be faster :P
05:53yasonChousuke: I'll have think about scaling later anyway
05:53yasonChousuke: but using atoms as the values sounds good now that I realize refs do a lot more than atoms
05:55yasontWip: Objects as in live Clojure primities, to be more exact. (Or as live as possible.:))
05:55Chousukehmm. if you wrap the values in atoms, it allows anyone to overwrite a value at anytime in the DB (atomically!), but they can't *add* to the database
05:55Chousukewithout going through the main ref that is
05:56yasonChousuke: adding to the database probably won't be a problem
05:56yasonChousuke: the single ref will probably handle that gracefully
05:57Chousukeyeah
05:57yasonChousuke: seems that swap! maps the old value through a function that returns the new value
05:57Chousukeyeah.
05:57yasonChousuke: in my case that's ideal since the value is in the transitions, not the exact value of the atom at each given time
05:58Chousukesounds good, then.
05:59yasonChousuke: What would've happened if I had put refs as values and wrapped a sweep over the values in a single dosync?
05:59clojurebotWhat is meta
06:00yasonChousuke: It would've compiled a list of refs in the transaction and somehow synced all of them for the calling thread?
06:00Chousukeyason: a dosync block restarts if there is a conflict
06:02Chousukeso you should actually do (doseq [[k v] @map] (dosync (alter v somefunc))) so that the ENTIRE map isn't resweeped
06:02Chousukeif you were using refs
06:03yasonChousuke: so in practice the transactions would be likely to restart many times during concurrent access?
06:03Chousukedepends on how small the transaction is.
06:04Chousukein my dosync, the transaction only concerns one ref at a time; if you move the dosync outside doseq, it'll concern the whole map.
06:04yasonChousuke: I was imagining mapping/filtering (seq @myhashmap) or something inside a dosync
06:05yasonChousuke: Indeed it sounds more sensible to not dosync the whole operation
06:05Chousukeyou should use doseq instead of a map, since map is lazy
06:06Chousukethat might not matter if the time when the transition happens doesn't matter to you.
06:06Chousukeie. if everything is commutative
06:09yasonChousuke: In this case I had in mind doall would probably been it
06:10yasonbut anyway, thanks again for your thoughts
06:11yasonI'll hopefully be able to contribute something back to the channel after hacking with Clojure long enough :)
08:25mib_9i23yehas anyone used clojure to develop for mobile devices?
08:32cddrhow would one return the first element of a sequence for which (pred elem) returns true?
08:35Chouser(first (filter pred coll))
08:36MikeSeththats an interesting question, is there a jme port anywhere?
08:36cddrChouser: so does filter return a lazy sequence?
08:36Chousercddr: yes
08:36vyChouser: Isn't it quite inefficient that it requires to scan whole list regardless of the first non-NIL result?
08:37cddrcool
08:37vyOops. Cool.
08:38mib_9i23yej2me anyone?
08:39rhickeymib_9i23ye: I think j2me might be too minimal for Clojure
08:44Carksooo there it is ... i have my first clojure program in production !
08:44Carka license server for another program, i already talked about it
08:44ChouserCark: nice!
08:44Carki'm pretty happy =)
08:45rhickeyCark: congrats!
08:46Carkwe tested it with 20 thousand simultaneous connections, looks like it will be good for a couple years
08:46Carkusing nio
08:47Carkall of the ssl/nio stuff was done in clojure itself
08:47Carkactually everything was done in clojure
08:48MikeSethi should start pushing this shop here off php and to clojure
08:49Carkwhat i didn't like (always easier to talk about the bad things) : spotty completion in emacs (not using slime)
08:49Carkalso : multimethods didn't cut it for the all connection->sll connection->line connection->license connection thing
08:50ChouserCark: because of flexibility or performance?
08:50Carkflexibility
08:51Carkm�hh how to explain this
08:52Carki was missing something like call-next-method
08:52Carki think that's the gist of it
08:52Chouserah.
08:53Carkanyways, building anonymous functions and putting these in a map achieves the goal, so that was no big deal
08:54rhickeyCark: there is get-method
08:54Chouserthere was some discussion of that, which resulted in a new feature, but I don't remember the specific ...
08:54rhickey,(doc get-method)
08:54clojurebot"([multifn dispatch-val]); Given a multimethod and a dispatch value, returns the dispatch fn that would apply to that value, or nil if none apply and no default"
08:55Chouserthen again, fn's in a map are likely faster, so if they serve the purpose then great.
08:56Carkright, i didn't see how get-method would be usefull, it was adding another field in my map
08:56rhickeywhile not a blind next-method, you could (get-method foo-method my-parent-dispatch-val)
08:56chessguy_workcan a macro raise an error?
08:56MikeSethrhickey: is it your estimate that clojure wont be available on mobile platforms any soon?
08:57Chouser,(doseq x)
08:57clojurebotjava.lang.IllegalArgumentException: doseq requires a vector for its binding
08:57Chouserchessguy_work: like that?
08:57chessguy_workyep :)
08:57marklarMikeSeth: You can write Android apps with it already
08:57chessguy_workso it's a compile-time error then
08:57rhickeyMikeSeth: people are playing with it on Android now
08:57Chouserchessguy_work: sure. or the macro can emit code which throws the exception, and then you have a runtime error.
08:57MikeSethmmmm delicious
08:58marklarMikeSeth: Check out http://github.com/remvee/clojurehelloandroid/tree/master
09:01chessguy_workhow evil is it for a macro to evaulate some of the code passed t oit
09:01Carkchessguy_work : you mean using eval ?
09:02chessguy_workor just unquoting and applying a function
09:02Carkwell that's one of the goals of macros
09:03Carkthe doseq macro, it does evaluate the body
09:03Cark,(doseq [i '(1 2)] (println i))
09:03clojurebot1 2
09:03Chouserusing 'eval' is hardly ever what you want, even in a macro
09:04Carkthe println form gets evaluated
09:04ChouserCark: yes, but not by using 'eval' in the macro.
09:04Carkright
09:04chessguy_workyeah, having done a lot of JS programming, i tend to read 'eval' as 'evil
09:04chessguy_work''
09:05chessguy_work,(expand-macro '(doseq [i '(1 2)] (println i))
09:05clojurebotEOF while reading
09:06chessguy_work,(expand-macro '(doseq [i '(1 2)] (println i)))
09:06clojurebotjava.lang.Exception: Unable to resolve symbol: expand-macro in this context
09:06chessguy_workbah, what the heck is it calle
09:06svdmmacroexpand
09:06chessguy_work,(macroexpand '(doseq [i '(1 2)] (println i)))
09:06clojurebot(loop* [G__2700 (clojure.core/seq (quote (1 2)))] (clojure.core/when G__2700 (clojure.core/let [i (clojure.core/first G__2700)] (do (println i)) (recur (clojure.core/next G__2700)))))
09:06chessguy_workeep
09:08chessguy_workerr
09:08chessguy_workwhat did doseq evaluate there?
09:09MikeSethrhickey: out of curiousity, has it ever occured to you that lispy languages need better code visualization during development?
09:09MikeSeth(the question goes to everyone really)
09:09Chouserit didn't evaluate anything -- it inserted the (println i) expression into its output, so that it would be evaluated at runtime.
09:10chessguy_workthat's what i thought
09:10chessguy_workso the macro doesn't evaluate any of its parameters
09:10chessguy_workdo other macros?
09:12rhickeyMikeSeth: both enclojure and IntelliJ's La Clojure have structure browsers, enclojure's also has multimethod grouping
09:12jdzchessguy_work: macros don't evaluate their parameters, by definition.
09:12chessguy_worklike, they literally can't?
09:12MikeSethlast time i tried enclojure it was too broken :(
09:13MikeSethbut that was a long time ago
09:13jdzchessguy_work: macro is just a function, which gets some clojure values in, and produces another clojure value.
09:13jdzchessguy_work: the values it gets in are not evaluated.
09:14jdzchessguy_work: as opposed to functions, which always receive their argumentns evaluated.
09:14jdzarguments even
09:14Carkbut nothing prevents a macro evaluating its arguments
09:14jdzyes, one just has to remember when the macros are being executed, which is compile time, not runtime.
09:15Chouserchessguy_work: you can use 'eval' in a macro, but usually it's not the right way to solve the problem at hand.
09:15chessguy_workChouser, is taht the only way to evaulate in a macro?
09:17asbjxrnMikeSeth what do you mean by code visualization?
09:23Chousukechessguy_work: you can use ~ inside syntax-quote
09:23Chousukeor hm
09:24chessguy_workto unquote it, right?
09:24ChousukeI guess that doesn't actually evaluate them
09:24chessguy_workbut then you could (let [foo ~foo] (foo 1 2)) right?
09:25Chousuke,(let [foo 5] [`foo `(foo ~foo)])
09:25clojurebot[sandbox/foo (sandbox/foo 5)]
09:25Carklet's say you want to make a loop unrolling macro (unroll 3 (println "hello"), you could check at macro expansion time that the first argument is an integer and use it to make your 3 calls to println
09:26Carkor actually to output the 3 println forms
09:26Chousukebut checking explicitly for an integer would prevent it from working with variables
09:26Carkone could say that the first argument is evaluated
09:26Chouserright, but (let [x 3] (unroll x (println "hello"))) wouldn't work.
09:26Carkyou wouldn't unroll a variable number of times
09:27Carkthat's part of this macro's api
09:27Chousukeright.
09:27Carkor specification
09:28Carkthough that's some braindead macro right there =)
09:29Chousuke(defmacro unroll [times body] `(do ~@(replicate times body)))
09:29Chousukedoes that work?
09:30Chousukehm, I guess it needs the &
09:30Chousukeno, I get a nullpointer exception ;(
09:30chessguy_workd'oh
09:30chessguy_workder suckage
09:31chessguy_worksurely that's a bug
09:31Chousukein my macro perhaps
09:31chessguy_workerr
09:32chessguy_worksorry, a null pointer exception at compile time is a compiler bug, IMHO
09:32Cark(defmacro unroll [times & body]
09:32Cark `(do ~@(replicate times `(do ~@body))))
09:32Carkugly =)
09:32Chouser,(intern 'sandbox '#^{:macro true} unroll (fn [times body] `(do ~@(repeat times (cons `do body)))))
09:32clojurebot#'sandbox/unroll
09:32Chouser,(unroll 3 (println "hi"))
09:32clojurebot"hi"
09:33chessguy_workalthough...i guess at this point, if you're evaluating things at compiletime, you've really got turing-complete compilation
09:33Chouser,(unroll 3 (print "hi "))
09:33clojurebot"hi "
09:33Chouserhm.
09:33chessguy_work,(macroexpand '(unroll 3 (println "hi")))
09:33clojurebot(do (do println "hi") (do println "hi") (do println "hi"))
09:33Chouserdoh
09:34chessguy_work,(do (do println "hi") (do println "hi") (do println "hi"))
09:34clojurebot"hi"
09:34Chousukechessguy_work: yes
09:34chessguy_work,(do (println "hi") (println "hi"))
09:34clojurebothi hi
09:35Chouser,(intern 'sandbox '#^{:macro true} unroll (fn [times body] `(do ~@(repeat times `(do ~body)))))
09:35clojurebot#'sandbox/unroll
09:35Chouser,(unroll 3 (println "hi"))
09:35clojurebothi hi hi
09:36Chousuke(defmacro unroll [times body] `(do ~@(repeat times body))) works too
09:36cddrwhat's the equivalent of funcall?
09:36MikeSethasbjxrn: well, since lisp syntax is trivial, you do not *have* to write and edit code as plain text
09:36Chousercddr: you don't need it. just put the variable in the first position.
09:37cddrah
09:37Chousercddr: lisp 1 ftw.
09:37Cark(defmacro unroll [times & body] `(do ~@(apply concat (replicate times body))))
09:37Carkthat's better !
09:37MikeSethasbjxrn: with some thought I suppose you can visualize code and relations between code parts as e.g. 2d graphs, 3d models and so on
09:40cp2Unspecified vulnerability in Java Runtime Environment (JRE) for Sun JDK and JRE 6 Update 10 and earlier; JDK and JRE 5.0 Update 16 and earlier; and SDK and JRE 1.4.2_18 and earlier allows untrusted applets and applications to gain privileges via unknown vectors related to "deserializing calendar objects."
09:40cp2hmm
09:43Chouser,(intern *ns* '#^{:macro true} _defmacro (fn [n & a] `(intern *ns* '~(with-meta n {:macro true}) (fn ~@a))))
09:43clojurebot#'sandbox/_defmacro
09:43Chousukecp2: I tested a proof of concept of that vulnerability :P
09:43Chousukeit worked pretty well ;(
09:44cp2yeah, so it seems
09:44asbjxrnMikeSeth: I see. I've never been a big fan of software through pictures. Text is very "condensed", making pictures out of it doesn't really add much I find.
09:44Chousukeasbjxrn: perhaps you've never seen a good visualisation :)
09:45MikeSethasbjxrn: well, I am talking here mostly about elimination of irrelevant visuals, quick navigation and so on, not about VB-style "yes you too can be a programmer" development
09:45asbjxrnThat is entirely true, I never have :)
09:48asbjxrnMikeSeth: I understand, and I'm probably the least experienced programmer here, but I find proper indentation of lisp code gives a reasonably good and dense representation of the code.
09:49MikeSethasbjxrn: without question. I'm just saying that original approaches could be superior
09:49asbjxrnWhen visualizing code in my head, it's more about abstractions and invariants than the tree as such.
09:52Chousukewith an image you could densely represent a much larger set of relations though.
09:52Chousukeso it might be good for getting an overview.
09:53Chousukeor quick code review: if it looks sensible, you probably don't need a redesign.
09:56asbjxrnChousuke: It's possible, and it would be interesting to see something like that, but the challenge is that you need to see the details at the same time.
10:03Chousukehttp://code.activestate.com/recipes/576766 D:
10:22marklarIs there a clojure way to write/read structs to/from a file? Or are we supposed to use the Java IO classes?
10:25Chouseryou can print and read maps as text, if you want.
10:27marklarChouser: In clojure? I've got it writing to a file using the Java IO, but was wondering if there is a cleaner way.
10:30Chouser,(prn {:a 1 :b 2})
10:30clojurebot{:a 1, :b 2}
10:30marklarChouser: thanks!
10:30Chouseryou could write that to a file, and read it in again later
10:31Chouserthat's all I mean. It's very good for some scenarios, not so much for others.
10:31marklarChouser: That was exactly what I was looking for I think, it prints to *out* right?
10:31marklarI just need something very simple
10:32ChouserYep, use (binding [*out* file-stream-thing] (prn ...))
10:32marklark, thanks again!
10:32hoeckmarklar: you may want to use clojure.contrib.duck-streams/spit too
10:32marklarhoeck: I'll take a look, I need something very simple though so I think prn will work
10:32marklarthanks
10:33hoeckmarklar: that's the simplest way of writing sth. to a file I can imagine :)
10:33marklarhoeck: then I'll definitely take a look :)
10:36alrex021How do I pronounce clojure? Is it like closure? :)
10:36rhickeyalrex021: yes
10:36alrex021thx
11:18Chouseris the only way to compile from the command-line like: java -cp clojure.jar clojure.main -e "(compile 'my.thing)" ?
11:19Chouserwell, I guess it's sufficient.
11:20rhickeythere is clojure.lang.Compile
11:21Chouserhmph. I was looking for that in main.clj
11:22Chouserok, thanks.
11:33triddellI see two main json libraries, danlarkin's and stuart sierra's in contrib... anyone know why someone might use one over the other?
11:33danlarkin_triddell: at this point I'd say probably go for stuart's
11:33danlarkin_unless you see some compelling reason to use mine
11:34liwphas anyone seen the following on windows with slime:
11:34liwp16:19 <Chouser> ok, thanks.
11:34liwp16:25 *** svdm QUIT Read error: 104 (Connection reset by peer)
11:34liwp16:25 *** svdm JOIN
11:34liwp16:29 <triddell> I see two main json libraries, danlarkin's and
11:34liwp stuart sierra's in contrib... anyone know why
11:34liwp someone might use one over the other?
11:34liwp16:30 <danlarkin_> triddell: at this point I'd say probably go for
11:34liwp stuart's
11:34liwp> has anyone seen the following on windows with slime: java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
11:34liwpurgh, sorry about that
11:34AWizzArdIs there a function (maybe in contrib) that allows me to ask yes/no questions as input from the keyboard?
11:35liwphas anyone seen the following on windows with slime: java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
11:35liwpbasically slime fails to run clojure and keeps polling until I abort it
11:36triddelldanlarkin_: I saw he stated "If you want indented output, try the clojure-json library at http://github.com/danlarkin/clojure-json&quot;... which would be nice, but I didn't know of any other major differences.
11:36cp2AWizzArd: dont think so
11:36dnolenliwp: are you using Clojure 1.0?
11:36cp2maybe you should make one!
11:36cp2and submit
11:36cp2to contrib
11:36liwpdnolen: svn HEAD
11:36dnolenliwp: using 1.0
11:37dnolener use i mean.
11:37ChouserAWizzArd: read-line is the closest thing I know of.
11:37liwpdnolen: OK, I'll give it a try. The same setup works fine on OS X at home, so I'm a bit confused. Thanks.
11:39AWizzArdChouser: probably that's enough for me
11:39danlarkin_triddell: yeah they're very similar at this point. stuart's has the advantage of being in contrib, so one less dependency
11:41triddelldanlarkin_: ok, thanks for the feedback
11:43alrex021I've seen the ClojureBox for Win project. Looks really cool. Are there any instructions (or recommendations) for getting a similar setup for a Mac OS X?
11:45liwpdnolen: FYI: it's broken with 1.0 as well. I must have messed up my slime environment somehow. I'll have to look into it more carefully some other time. Cheers.
11:47marklarliwp: i've been dealing with the same issue on a linux box, haven't been able to figure it out either :(
11:50chessguy_work,(let [f (fn [x] (. Character isDigit x))] (f 5))
11:50clojurebotfalse
11:50chessguy_work,(let [f (fn [x] (. Character isDigit x))] (f '5'))
11:50clojurebotUnmatched delimiter: )
11:50AWizzArdI have a file src/de/company/foo.clj which looks like (ns de.company.foo) (defn main [& args] (apply println "Args:" args)). Now I would like to call that main function from the command line. How can I do this? java -cp src/;clojure.jar de.company.foo.main 10 20 does not work.
11:50chessguy_work,(let [f (fn [x] (. Character isDigit x))] (f "5"))
11:50clojurebotjava.lang.IllegalArgumentException: No matching method found: isDigit
11:52chessguy_work,(let [f (fn [x] (. Character isDigit x))] (f \5))
11:52clojurebottrue
11:53cp2marklar: marklar marklar, marklar marklar marklar!
11:55marklarcp2: I've always thought the same thing
11:55cp2heh
11:55cp2sorry, i just saw your name and it reminded me =)
11:55marklarcp2: np :)
11:59chessguy_work,(\5)
11:59clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn
12:00chessguy_work,\5
12:00clojurebot\5
12:01AWizzArdjava -cp src/;clojure.jar clojure.main -e "(do (use 'de.company.foo) (main 1 2 3))" also does not work. Any ideas how I can call that main function from the command line?
12:01rhickeyAWizzArd: did you try that with latest trunk?
12:02AWizzArdno, I will do this right now
12:03Cark,(doc defsymbolmacro)
12:03clojurebotjava.lang.Exception: Unable to resolve var: defsymbolmacro in this context
12:04Carkthere is a thread talking about symbol macros on the mailing list, is that from a library ?
12:06Carkok found it in clojure contrib =)
12:06Carknow why would this be bad ?
12:12Chousukewhat, defsymbolmacro?
12:13cp211:02 < Cark> ok found it in clojure contrib =)
12:13Carksymbol macros, rich is saying he's "a bit concerned by the need of symbol macros"
12:15cp2what is a symbol macro?
12:15Carksome kind of a macro that willl be expanded with just the symbol
12:16Carklike i could expand the symbol 'hello to (println "hello")
12:16cp2oh
12:16cp2hm
12:16cp2not sure i like that idea =\
12:17Carkthat's a silly example, but there are cases where it would be usefull
12:17cp2yeah i can imagine
12:17ChouserCL has them?
12:17Chousukeyes
12:52rhickeyany good tokyo cabinet libs for Clojure?
12:53rsynnottwell, there's a java api...
12:54rhickeyrsynnott: got that
12:55rsynnottit's a simple enough library in terms of interface provided that a wrapper might nearly be overkill
12:55rhickeya wrapper would let it work with all Clojure map and seq functions
12:55clojurebotmap is *LAZY*
12:56rsynnottoh, I suppose so, yes
12:57cddrhas anyone written a "clojure for cl programmers" tutorial?
12:58danlarkin_I have a couchdb library that I'm working on... but that's not tokyo cabinet...
13:01Chouserwe're using tokyo cabinet, but not from clojure (yet)
13:01technomancyanyone using S3 from clojure?
13:01Chouserfascinating array of "no"s there.
13:02technomancyit looks like it's a simple matter of a bunch of rest calls, not really much room for a library to abstract things
13:03rhickeyI wonder how well tokyo cabinet's threading/lock stuff plays with Java
13:03rhickeytechnomancy: not tyrant, the cabinet directly embedded
13:04rhickeyhow about jdbm?
13:11danlarkin_*crickets*
13:16cddrhas anyone written a "clojure for cl programmers" tutorial?
13:16cddrsorry, didn't mean to report my earlier comment
13:17technomancycddr: there's a video of a presentation rich gave to a Lisp group that would probably be helpful
13:17technomancyit's not too specific to CL, but it addresses folks coming from a lispy background
13:22AWizzArdbtw rhickey, with the new checkout I can run java -cp src/;clojure.jar clojure.main -e "(do (use 'de.company.foo) (main 1 2 3))" and indeed call my main method with that successfully.
13:22AWizzArdThanks for the hint :)
13:29rhickeycddr: not that I know of, I presume you've seen http://clojure.org/lisps
13:33technomancyoh snap; the oreilly scala book is free online
13:33technomancy... and the second word of the first chapter is "enterprise". didn't see _that_ coming. =)
15:01triddellrhickey: Clojure-DBM is an interface to key/value databases like Tokyo Cabinet... http://github.com/weavejester/clojure-dbm/tree/master ... from the man behind compojure. I think it was just an initial but something to fork and enhance maybe
15:02sopelhey
15:03sopelany idea how to cast a Clojure vector to a byte array so that i can write it to a java outputstream?
15:05Chouservector of...? Integers?
15:05sopelyeah
15:05Chouser,(into-array Byte/TYPE (map byte [1 2 3 4]))
15:05clojurebot#<byte[] [B@8ccbe7>
15:06sopeloh, thanks.
15:06sopeli'm working with sockets, it's pretty cumbersome.
15:08durka42hmm, SwingUtilities/invokeLater swallows exceptions doesn't it
15:13Chouserrhickey: What would you require of a Contributor's employer to be comfortable with patches originally owned by that employer?
15:13Chousera specific signed document with their name and yours?
15:13Chousera general written corporate policy that employees my submit patches to open source projects?
15:13Chousers/my/may/
15:14rhickeyChouser: should be a CA from employer
15:14sopelhow to find the names of classes of base clojure datastructures? i want to derive them
15:15sopelfor multimethod dispatching
15:15Chouserso the employer would then retain the copyright
15:15Chouser,(class {})
15:15clojurebotclojure.lang.PersistentArrayMap
15:15Chousersopel: like that?
15:15Chouser,(class (hash-map))
15:15sopel:)
15:15clojurebotclojure.lang.PersistentArrayMap
15:15Chouser,(class (hash-map :a 1))
15:15clojurebotclojure.lang.PersistentHashMap
15:15rhickeyChouser: yup
15:15sopelyea pretty simple. thanks. still learning.
15:15Chouserrhickey: ok, thanks.
15:15rhickeyfrom the CA: "If this contribution is on behalf of a company, the term 'you' will also mean the
15:15rhickeycompany you identify below"
15:16Chousersopel: note that there are many specific derived types, and some important interface types.
15:16rhickeyooh, La Clojure adds a REPL!
15:16sopelok.
15:17mattreplafter "use"ing a Clojure source file containing derives that don't explicitly reference a hierarchy, there seems to be no affect on the global hierarchy. is that correct behavior?
15:17noidiis it possible to use ctags with clojure?
15:18Chouserrhickey: ah. hm -- but that looks like my signature would be sufficient if my employer has a policy that authorizes me to sign the contract.
15:18sopelChouser; oh, LazilyPersistentVector alread ypopped up.
15:19mattreplfor example, using c.c.json.write and trying (json-str (doto (java.util.ArrayList.) (.add 1) (.add 2))) will print using ArrayList#toString instead of the proper formatting "[1,2]"
15:19rhickeyChouser: this has to be true:
15:19rhickey With respect to your contribution, you represent that:
15:19rhickeyo it is an original work and that you can legally grant the rights set out in these terms;
15:20danlarkinmattrepl: c.c.json probably doesn't have a default dispatch for j.u.ArrayLists, you can add one with defmethod though
15:20somethingI'm trying to consume PersistentStructMap from jruby, not sure how to access the values in the map.
15:20mattreplbut after a load-file of c.c.json.write.clj, the hierarchy is in place and json-str works correctly.. or rather, the multimethod print-json works
15:20mattrepldanlarkin: that's what I thought, but there is one for java.util.Collection which should work for ancestors such as java.util.ArrayList, and it does after the load-file
15:21rhickeyChouser: so, depending on your policy/authorization, yup
15:22sopelhum, interesting. i wrote some bytes to a socket but didn't flush it. and the other end read null bytes from the socket. when i flush it it gets the right data on the other end.
15:22rhickeyChouser: I've gotta run soon, does that make sense?
15:22Chouserrhickey: well, I'm trying to help form the policy
15:22ChouserI've never had so much fun. :-P
15:22rhickeyfair enough :)
15:22Chouseryep, thanks.
15:22danlarkinmattrepl: curious...
15:23rhickeythe Sun CA is certainly commercial friendly, they got Google and Red Hat to sign it. Contributors really give up nothing, just share
15:25danlarkinmattrepl: use parents/ancestors/descendants and isa? to query the hierarchy
15:25danlarkinafter the use
15:26mattrepldanlarkin: did that, and didn't see modification as I would expect if print-json isn't dispatching correctly
15:29danlarkinmattrepl: after using I run: (ancestors java.util.Collection) and it returns #{:clojure.contrib.json.write/array java.lang.Iterable}
15:29mattreplgood, at least it's just me... one moment
15:31mattreplyeah, I just restarted the session and I'm only seeing Iterable after the use. must be configuration error, thanks for sanity check
15:32somethingI tried to use the indexer in jruby or get method to access PersistentStructMap. It always return nil. the toString of the map shows there is data.
15:33danlarkinmattrepl: what version of clojure are you running?
15:33mattreplit's post 1.0, I believe
15:34marklar_How does one checkout the 1.0 version of clojure from the googlecode page? I've never used svn before...
15:34danlarkinmattrepl: ok, just checking... I'm on latest SVN
15:38hiredmanmarklar_: I would just download the zip
15:39marklar_hiredman: I need to make some changes
15:39hiredmanI am not 100% sure but I think the zip includes sources
15:40danlarkinmarklar_: you can just use the path when you checkout... so it's whatever... svn co code.google.com/clojure/tags/1.0
15:40marklar_hiredman: you know, I think you're right
15:40marklar_danlarkin: thanks, tags was what I was looking for
15:43cemerickargh, I've been down this path before: if I require some namespace with an alias (:require [com.foo.bar :as bar]), how do I name a keyword using that alias? :bar/kw is kw in the bar namespace, not the com.foo.bar namespace...
15:44hiredmanthis does sound familar
15:45cemerickRich set me straight on it about 6 weeks ago, but it's come up again, I can't find my code from then, and I can't find the conversation in the channel log. ;-/
15:45danlarkinhow about using the two-argument form of keyword?
15:46cemerickdanlarkin: ech. There really is an elegant reader form that does it.
15:46hiredman2009:Apr:30:05:14:01 rhickey : ::myns/foo
15:47danlarkinhuman google
15:47hiredmanwell, I have my personal logs here on disk so I can just grep
15:47cemerickhiredman and clojurebot are actually just skynet v0.9
15:49danlarkinspeaking of, what the heck is this company thinking, naming themselves cyberdyne and building robots?!? http://www.cyberdyne.jp/english/index.html
15:49cemericknice
15:50p_ldanlarkin: afaik only exoskeletons for now
15:50danlarkinkara thrace harbinger of death
15:50cemerickthat's like the old joke about Wang coming to America, and not understanding what all the snickering was about.
15:55hiredmanclojurebot: functional programing?
15:55clojurebotHuh?
15:55hiredmanclojurebot: functional programing is <reply>http://jackcoughonsoftware.blogspot.com/2009/05/teaching-functional-programming-to-kids.html
15:55clojurebotIk begrijp
15:56p_ldanlarkin: also, notice the name of the system...
15:56p_ldanlarkin: "*Hybrid Assistive Limb*, and *HAL* are trademarks (TM) or registered trademarks (�) of CYBERDYNE, Inc."
15:56danlarkinHAL? yeah, they're so hip
15:57danlarkindownfall of humanity right here
15:57p_lNah, they are only making simple stuff. Fear the AGI research :D
15:58somethingis there an opposite of the bean function?
15:59hiredmannope
15:59hiredmanbecause beans are class and to make new classes you need to AOT compile
15:59hiredmanwell
15:59hiredmanbeans are instances of classes
15:59somethingAOT?
16:00hiredmanahead of time
16:00somethingi see.
16:00somethingit seems like it's possible
16:01hiredmanhttp://gist.github.com/34229 is a old (possibly not working) and lacking features (like types) macro for easily generating beans
16:02hiredmanof course you would still need a function to map a map to a bean
16:02sopelhow to make map non-lazy?
16:02hiredman(doc doall)
16:02clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
16:02hiredman(doc dorun)
16:02clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
16:02somethinghiredman, cool thanks
16:03sopeli'm using str for debugging, any neater way to print datastructures?
16:03sopel'cause (str somevector) isn't giving me the contents ;)
16:03hiredmanprn-str
16:04hiredman,(prn-str [1 2 3 4])
16:04clojurebot"[1 2 3 4]\n"
16:04hiredman,(str [1 2 3 4])
16:04clojurebot"[1 2 3 4]"
16:05sopelthanks
16:11HAppyKAmikazehello world
16:12somethingwas that from clojure?
16:43cemerickmmm, the "new" enclojure release is yummy so far
16:44mrsolowhy isn't cons lazy by default?
16:46technomancymrsolo: there's some overhead to lazy sequences
16:49mrsoloi take it the performance hit is very noticeable?
16:49technomancymrsolo: it _would_ be noticeable if you had to invoke it for every single cons call.
16:59cemerickI wonder...
16:59cemerick,(ref 5)
17:00clojurebot#<Ref@47dc79: 5>
17:00cemerick,(ref 5 :meta {:foo 0})
17:00clojurebot#<Ref@11e7af3: 5>
17:00cemerickhrm, that throws a classcast for me...
17:01durka42works for me
17:03cemerickdurka42: yeah, it's a sporadic error on my end. Not sure what to make of it.
17:44twismhow do you check if a map contains a key?
17:44danlarkin(doc contains?)
17:44clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
17:45twismif anyone knows that off head... im too lazy to browse the api
17:45twismthanks danlarkin
17:45danlarkinfind-doc is your friend
17:46hiredmanalso, maps are Collections so they have a .contains method
17:46hiredman,(.contains {:a 1} 1)
17:46clojurebotjava.lang.IllegalArgumentException: No matching method found: contains for class clojure.lang.PersistentArrayMap
17:46twismoh cool
17:46hiredmanoh
17:46hiredmanwait
17:46hiredmanMaps are not Collections
17:46hiredmanduh
17:46twismlol
17:46hiredmaneverything else is
17:46hiredman,(.contains [1 2] 1)
17:46clojurebottrue
17:47hiredman,(.contains [0 2] 1)
17:47clojurebotfalse
17:47twism,(contains? {:a 1} :a)
17:47clojurebottrue
17:47hiredman,({:a 1} :a)
17:47clojurebot1
17:48twismthanks guys
17:48twism#clojure is the best
17:48hiredman,(.keySet {:a 1})
17:48clojurebot#< [:a]>
17:48hiredman,((.keySet {:a 1}) :a)
17:48clojurebotjava.lang.ClassCastException: clojure.lang.APersistentMap$2 cannot be cast to clojure.lang.IFn
17:48hiredman,(get (.keySet {:a 1}) :a)
17:48clojurebotnil
17:49hiredman:(
17:53twismhiredman: isnt that right?
17:54hiredman,(:a (.keySet {:a 1}))
17:54clojurebotnil
17:54hiredman,(class (.keySet {:a 1}))
17:54clojurebotclojure.lang.APersistentMap$2
17:54twism,(doc get)
17:54clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
17:54hiredman,(get #{:a} :a)
17:54clojurebot:a
17:54twismhmm
17:54hiredman,(map #(.getName %) (.getMethods (class (.keySet {:a 1}))))
17:54clojurebot("contains" "size" "iterator" "hashCode" "equals" "removeAll" "add" "clear" "toString" "isEmpty" "addAll" "toArray" "toArray" "remove" "containsAll" "retainAll" "wait" "wait" "wait" "getClass" "notify" "notifyAll")
17:55hiredman,(.contains (.keySet {:a 1}) :a)
17:55clojurebottrue
17:55hiredman:(
17:58hiredmanhttp://farm3.static.flickr.com/2289/2126533900_30e4e1cd4f.jpg
18:25danlarkinif I'm conjing into an array-map, it should remain in the order the elements get conjed on, right?
18:29hiredmandanlarkin: until it becomes a HashMap, I believe so
18:30danlarkinoh, I see... this must be becoming a hash-map somewhere then
18:30hiredmanaround 8 to 10 entries
18:31danlarkinoh, even if I instantiate with (array-map)? I thought that would force it to remain one
18:31hiredman,(class (conj (array-map :a 1 :c 2 :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v :w :x :y :z :z) [:b 2]))
18:31clojurebotclojure.lang.PersistentHashMap
18:32danlarkindarn
18:32danlarkinI want an ordered map
18:32rsynnottfunny, really, you rarely see ordered maps
18:32clojurebotThe most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...' -- Asimov
18:33hiredmanpossibly a sorted set of keys?
18:33rsynnottI suppose they'd be a little expensive
18:33hiredmanhey
18:33hiredmanyeah, you could attach a sorted set of keys as metadata
18:34hiredmanof course you would need to wrap conj and assoc, etc
18:34danlarkinyeah, no good
18:35hiredmanI dunno that it is no good
18:35hiredmanyou just shove it in to d.lakin.sorted-map
18:35hiredmanexclude the core versions
18:36hiredman(:require [d.larkin.sorted-map :as sm])
18:36hiredmansm/assoc etc etc
18:36danlarkin:-/
18:37danlarkinthat's too much
18:38danlarkinit's a library, I can't really make people use dan.larkin.ordered-map/get for one map returned by one function
18:38danlarkinI wouldn't want to, even
18:46hlshipworking on a macro to define a function in another namespace
18:46hlshipso as to have access to that namespace's private defs
18:46hlshipcontext: using Clojure as a property expression language inside a template file (for cascade)
18:46hlshiphttp://paste.lisp.org/display/80573
18:47hlshipdoesn't seem to work, however
18:47hlshipuser=> (load-file "/Users/Howard/work/clojure/cascade/src/test/clojure/com/howardlewisship/cascade/test_utils.clj") java.lang.Exception: Unable to resolve symbol: double-talk in this context (test_utils.clj:23)
18:47hlshipIt's as if the (in-ns) doesn't work.
18:48technomancywasn't there a "with-ns" added that temporarily changes the namespace?
18:48hiredmanhlship: the namespace that def uses is determined durring compile time
18:48hiredmanso you need to use intern
18:48hiredman(doc intern)
18:48clojurebot"([ns name] [ns name val]); Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name symbol. Returns the var."
18:52hlshipthanks for the tip, but I'm not seeing what exactly should be "intern"-ed
18:53hiredmanhlship: the function
18:53hlshipSo, use (intern) rather than (defn)?
18:54hiredmansome like (intern (create-ns "some.namespace") (fn [] "foo"))
18:54hiredman,(doc create-ns)
18:54clojurebot"([sym]); Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing namespace of the same name."
18:55hlshipcan you point me at an example of someone doing this? It looks close to what I want anyway, as the final impl will use anonymous or inline functions
18:55hiredmanlemma take a look at your paste
18:57hiredmanhlship: so you are passing in something like (defn foo [] "foo") ?
19:01hiredmanbecause intern explicitly takes a namespace argument you wouldn't have to deal with in-ns back and forth
19:11mrsolohm clojurecheck, does it work?
19:20Chousukehiredman: you can use find-ns :p
19:21hiredmanChousuke: sure sure
19:22hiredmanbut create-ns acts just like find-ns, but it will create the ns if it does not exist
19:22mrsolooh. well quickcheck aspet isn't implemented yet..
19:54_hrrldI'm trying to use print and read to serialize a vector of strings and I'm getting owned:
19:54_hrrld(with-in-str (with-out-str (print ["a b c" "d e f"])) (read))
19:55durka42,(pr-str ["a b c" "d e f"])
19:55clojurebot"[\"a b c\" \"d e f\"]"
19:55durka42,(read-string (pr-str ["a b c" "d e f"]))
19:55clojurebot["a b c" "d e f"]
19:56_hrrldn1, thanks.
20:01mrsolo I am seeing something like this in core.clj.. what does it mean? [#^clojure.lang.IObj x m]
20:01mrsolotype casting?
20:01ataggarttype hint i think
20:02ataggartto avoid reflection
20:02mrsoloah thanks
20:03mrsoloanother question. what is (fn* ....)?
20:03mrsolo (fn* let [& decl] (cons 'let* decl))) for example
20:04ataggartdunno
20:04ataggartI dont see it being declared in any of the clj
20:04mrsolocore.clj
20:05mrsolobeing used that is
20:05ataggartya, I means fn* itself being declared. Given how high it is in clore.clj, I'd imagine it's in the java side
20:05ataggartin the processing
20:06ataggarterm.. reading
20:06ataggartjust a guess tho
20:07ataggartya, check out Compiler.java
20:07ataggartit's a symbol created amongst all th eother special forms
20:09mrsolooic.. thx
20:59beelee,(-> 2 (fn [x] (+ 1 x)))
20:59clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer
21:00beeleebut if i bind that fn to something it works?
21:03beelee,(let [f (fn [x] (+ 1 x))] (-> 2 f))
21:03clojurebot3
21:04dysinger,(System/exit 1)
21:04clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)
21:04dysinger:)
21:05durka42beelee: -> is translating the first form into (fn 2 [x] (+ 1 x))
21:06durka42,(-> 2 ((fn [x] (+ 1 x))))
21:06clojurebot3
21:06beeleehmm, i see what you mean
22:47danlarkinrhickey: any thoughts on adding an ordered-map to clojure? I have a use case that requires one
22:56rhickeydanlarkin: there is a sorted map
22:57danlarkinI want to sort by insertion order
22:59rhickeythen it's going to be a slow map
22:59rhickeymight as well just search for things in a vector
23:30sshackquick question. what do the []'s do?
23:31hiredmanvector literal
23:31hiredman,(class [])
23:31clojurebotclojure.lang.PersistentVector
23:31sshackahh. Okay, I see now.