#clojure log - May 20 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:08 duck1123_: How come I can't negate thrown? within an is macro?

0:09 I wanted to simply verify that a certain exception wasn't thrown

0:44 arohner: duck1123_: because "is" is a multimethod that dispatches on the first form passed to it

0:45 I assume you'd like to do (is (not (thrown? ...)))

0:45 you have a good use case. post a message to the group

1:33 seangrove: hey guys, wondering what the options are for automated testing before I dive into the clojure world?

1:41 cads: what converts :key into "key"?

1:41 hiredman: ,(doc name)

1:41 clojurebot: "([x]); Returns the name String of a symbol or keyword."

1:42 cads: 'doh I ought to know that

1:44 arohner: seangrove: there is test-is in clojure-contrib

1:46 seangrove: arohner: have you worked with it much?

1:46 arohner: yeah. It's running as we speak :-)

1:46 it's your standard test framework

1:46 oh, there's also fact

1:47 seangrove: ah, cool

1:47 arohner: http://github.com/weavejester/fact/tree/master

1:47 it's kind of like haskell's quickcheck, if you're familiar with that

1:47 seangrove: haven't dabbled with clojure at all yet, just wanted to make sure that was covered before I get too far into it

1:47 arohner: nah, I haven't done any heavy functional programming

1:48 mainly just some mall scheme and CLOS projects

1:48 cads: is there a function sym such that (apply #([% (class %)]) (sym "dog" 123 'cat :bat)) => [dog123catbat clojure.lang.Symbol]

1:49 hiredman: that would not work

1:49 for a number of reasons

1:49 ,(symbol "foo")

1:49 clojurebot: foo

1:50 cads: ,(symbol (str "rat" "cat" 123 "hellbat"))

1:50 clojurebot: ratcat123hellbat

1:50 replaca: ,(symbol (str :bat))

1:50 clojurebot: :bat

1:50 cads: ,(symbol (str "rat" "cat" 123 (name :bong) "apple"))

1:50 clojurebot: ratcat123bongapple

1:50 hiredman: a. (sym "dog" 123 'cat :bat) would try and call sym on the args "dog" 123 'cat :bat and there is no function named sym

1:51 b. your function literal there takes one arg

1:51 replaca: hiredman: he as using sym as the free variable in his question

1:51 *as => was

1:51 cads: I think I could write sym in 3 lines

1:51 hiredman: wait

1:51 so you got "sym" but couldn't find "symbol" on the api page?

1:52 replaca: java-utils/as-str might help here

1:52 hiredman: you're not understanding what he meant by "sym"

1:52 replace it with foo in his question

1:53 is there a function "foo" such that ... (foo "dog" 123...)

1:53 ?

1:54 hiredman: replaca: yes, and the function symbol is more or less what he was looking for

1:54 cads: hired 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.

1:55 hiredman: ,((comp symbol (partial apply reduce str)) "dog" 123 'cat :bat)

1:55 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword

1:55 cads: ,(name "str")

1:55 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Named

1:56 cads: ,(symbol "te:st")

1:56 clojurebot: te:st

1:57 cads: ,(defn sym [& glargs] (symbol (apply str glargs)) (sym "hyper" 'rat :cat)

1:57 clojurebot: EOF while reading

1:57 cads: ,(defn sym [& glargs] (symbol (apply str glargs))) (sym "hyper" 'rat :cat)

1:57 clojurebot: DENIED

1:58 cads: hehe, it yiels hyperrat:cat

2:06 replaca: (defn catsym [& args] (symbol (apply str (map as-str args))))

2:06 where as-str is defined in clojure.contrib.java-utils

2:07 (catsym "dog" 123 'cat :bat) => dog123catbat

2:08 cads: I think that's what you're after, right?

2:09 ~def as-str

2:09 ~doc as-str

2:09 clojurebot: Titim gan �ir� ort.

2:09 replaca: oh well

2:34 jdz: as far as i can see there is no way to throw an exception with some data in it, right?

2:34 replaca: jdz: well, you can, but you need to create your own exception class and gen-class it

2:35 jdz: and then it will probably be wrapped

2:35 jdz: that is what i want to avoid doing

2:35 because gen-class requires compilation

2:36 something akin to CL's throw/catch would be cool, and could be implemented using Java exceptions

2:36 replaca: I used a method in cl-format where I built error information lower down with a special function

2:37 you might also want to look at Chouser's error-kit in contrib

2:37 jdz: that is actually what i need, non local transfer of control with some data passing

2:37 ye, will look at error-kit, maybe there's something cool.

2:37 replaca: in cl-format, I only wanted to be able to end up with a more sophisticated RuntimeException, so it may not be sufficient for you

2:38 I haven't tried error-kit yet, but I want to :-)

2:38 but I haven't written code that does anything but die on errors since Chouser wrote it

2:39 jdz: there's a pretty hackish thing in contrib/except

2:39 replaca: oh, I haven't looked at that. I thought it was just cleaning up error messages

2:41 looking at contrib/except, it doesn't look like what you're after

2:41 just convenience wrappers

2:43 jdz: hmm, looking at error-kit it seems i can use proxy after all...

2:43 somebody's really smart around here :)

2:44 replaca: yeah, Chouser's spent a lot of time understanding how Clojure really works

2:45 are you looking at his proxy + IDeref trick?

2:45 clojurebot: proxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.

2:45 jdz: ye, the IDeref thing

2:46 replaca: yeah, that's clever. I want to play with it, too

2:48 time for bed!

3:14 cads: replaca, that's it :)

3:15 ~def str

4:16 opqdonut: can i somehow "store" a set of bindings that's in effect at some point, and eval something in that context later?

4:18 essentially, 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 ...))"

4:18 the expressions aren't evalled until much later, and arg won't be in scope then

4:20 hoeck: opqdonut: with "bindings", do you mean dynamic vars?

4:21 opqdonut: or just values bound in a let-form?

4:27 jdz: opqdonut: macros are run at compile time; when your program executes, all macros have been substituted by corresponding code.

5:02 opqdonut: hoeck: let-form

5:14 wnong: a terrible beginner here (to clojure as well as IRC)

5:16 i am a the getting started with the prag-prog book and am getting error with jline/consoleRunner (NoClassDefFoundError)

5:23 jdz: never used that, so all i can suggest is to use the exact version of the software that is used in the book.

5:23 wnong: i have the same version from the book.

5:25 so far i have found ..googling that it is something to do with the absolute path (of jline.jar). I tried this too.

5:25 Chousuke: probably misconfigured classpath

5:25 it's in the wrong directory

5:25 the jar that is

5:25 wnong: i have all the jars in the /lib directory

5:25 including the clojure.jar

5:26 Chousuke: and how do you run clojure?

5:27 wnong: i have been doing simple test runing the clojure.jar itself

5:27 but now i am going by the book and trying to run the script (repl.sh)

5:27 and get this error "Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner"

5:28 Chousuke: probably the repl.sh sets up the classpath wrong.

5:29 lisppaste8: url

5:29 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

5:29 Chousuke: paste its contents there

5:29 wnong: ok

5:31 lisppaste8: wnong pasted "prog-clojure-book-getting started" at http://paste.lisp.org/display/80539

5:31 wnong: done

5:32 Chousuke: is htat CLOJURE_DIR path correct?

5:32 does it contain your /lib?

5:32 jdz: and are the newlines really where they appear in the paste?

5:32 wnong: yes

5:32 yes

5:33 there are 3 lines

5:33 jdz: there is a space between : and classes

5:34 wnong: i fixed that now and same error

5:34 jdz: and $CLOJURE_JAR is not used, btw.

5:35 Chousuke: jdz: that doesn't matter; it's in the classpath anyway

5:35 jdz: yes, i'm just saying

5:35 if it's not used, it should not be theer

5:35 wnong: yes, i was trying to modify it according the wiki-book

5:35 jdz: there even

5:36 Chousuke: did you check if the lib dir actually contains jline-0.9.94.jar

5:36 wnong: I tried testing the jline itself going thru http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Linux

5:37 yes jline version is in the lib dir

5:38 from the link above, i was trying out : java -cp $CLOJURE_DIR/jline-VERSION.jar:$CLOJURE_JAR \ jline.ConsoleRunner clojure.lang.Repl

5:38 Chousuke: uh, VERSION?

5:38 wnong: ofcourse replacing the version with my jar-name

5:38 Chousuke: right.

5:39 and it's the 0.9.94 version?

5:39 yason: Which 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?

5:39 wnong: yes it is

5:39 Chousuke: really weird

5:39 ensure that your CLOJURE_DIR has no typos

5:39 yason: In other words: is it ok to sow refs around like mad rather than use them sparingly?

5:39 Chousuke: that's the only thing I can think of anymore.

5:40 wnong: ok..will check again. thx for ur time

5:41 Chousuke: yason: if you're using many Refs, you're most likely trying to emulate mutability somehow.

5:41 yason: the fewer refs you have, the less code you have to coordinate with dosync.

5:41 yason: Chousuke: I have a single hashmap that contains most of the mutable state of my program.

5:42 hoeck: yason: depends on your granularity needs

5:42 Chousuke: a single ref for that is fine in many cases.

5:43 yason: Chousuke: 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

5:44 Chousuke: at the very least, you should avoid storing each database entry in a ref.

5:44 yason: hoeck: 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

5:44 hoeck: On the other hand, I need to read / filter values from the whole database at times, which would mean dereffing a lot of refs

5:45 hoeck: yason: maybe use atoms then for the hashmaps values?

5:45 yason: Chousuke: Ok, so refs can be considered expensive, complexity-wise?

5:45 hoeck: If they're lighter, yes. I haven't got much "feel" for the differences of refs and atoms yet

5:45 Chousuke: well, they're trickier than just having immutable data, that's for sure :)

5:46 atoms are just holders for data that are atomically swappable, with no coordination of how the changes happen.

5:46 yason: Chousuke: 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

5:47 Chousuke: a ref is fine for that.

5:47 tWip: long running? how long? perhaps you could consider a database

5:47 Chousuke: clojurebot has its entire database of definitions in a single map with a single ref.

5:47 it's not very high traffic though.

5:48 but adding to the map is cheap even if it grows big.

5:48 yason: tWip: days, weeks. A database would be ok if I could easily shove Clojure objects there

5:49 tWip: using JDBC from Clojure is pretty easy

5:49 yason: tWip: isn't JDBC relational?

5:49 tWip: but I think Clojure would also be good for prevalence type solutions, if you want to have everything in memory

5:49 yeah jdbc is for sql databases mostly

5:50 Chousuke: if you want more granularity, you could also divide your database maps

5:50 cddr: In java, you can get at "this" during the constructor. Is that possible in a proxy?

5:51 yason: tWip: I'm more after object databases.

5:51 Chousuke: yason: 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

5:52 tWip: for some value of "object" I guess...

5:52 Chousuke: yason: though, overwriting might be a problem :/

5:52 hmm

5:52 nah, a single map would probably be faster :P

5:53 yason: Chousuke: I'll have think about scaling later anyway

5:53 Chousuke: but using atoms as the values sounds good now that I realize refs do a lot more than atoms

5:55 tWip: Objects as in live Clojure primities, to be more exact. (Or as live as possible.:))

5:55 Chousuke: hmm. 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

5:55 without going through the main ref that is

5:56 yason: Chousuke: adding to the database probably won't be a problem

5:56 Chousuke: the single ref will probably handle that gracefully

5:57 Chousuke: yeah

5:57 yason: Chousuke: seems that swap! maps the old value through a function that returns the new value

5:57 Chousuke: yeah.

5:57 yason: Chousuke: in my case that's ideal since the value is in the transitions, not the exact value of the atom at each given time

5:58 Chousuke: sounds good, then.

5:59 yason: Chousuke: What would've happened if I had put refs as values and wrapped a sweep over the values in a single dosync?

5:59 clojurebot: What is meta

6:00 yason: Chousuke: It would've compiled a list of refs in the transaction and somehow synced all of them for the calling thread?

6:00 Chousuke: yason: a dosync block restarts if there is a conflict

6:02 so you should actually do (doseq [[k v] @map] (dosync (alter v somefunc))) so that the ENTIRE map isn't resweeped

6:02 if you were using refs

6:03 yason: Chousuke: so in practice the transactions would be likely to restart many times during concurrent access?

6:03 Chousuke: depends on how small the transaction is.

6:04 in my dosync, the transaction only concerns one ref at a time; if you move the dosync outside doseq, it'll concern the whole map.

6:04 yason: Chousuke: I was imagining mapping/filtering (seq @myhashmap) or something inside a dosync

6:05 Chousuke: Indeed it sounds more sensible to not dosync the whole operation

6:05 Chousuke: you should use doseq instead of a map, since map is lazy

6:06 that might not matter if the time when the transition happens doesn't matter to you.

6:06 ie. if everything is commutative

6:09 yason: Chousuke: In this case I had in mind doall would probably been it

6:10 but anyway, thanks again for your thoughts

6:11 I'll hopefully be able to contribute something back to the channel after hacking with Clojure long enough :)

8:25 mib_9i23ye: has anyone used clojure to develop for mobile devices?

8:32 cddr: how would one return the first element of a sequence for which (pred elem) returns true?

8:35 Chouser: (first (filter pred coll))

8:36 MikeSeth: thats an interesting question, is there a jme port anywhere?

8:36 cddr: Chouser: so does filter return a lazy sequence?

8:36 Chouser: cddr: yes

8:36 vy: Chouser: Isn't it quite inefficient that it requires to scan whole list regardless of the first non-NIL result?

8:37 cddr: cool

8:37 vy: Oops. Cool.

8:38 mib_9i23ye: j2me anyone?

8:39 rhickey: mib_9i23ye: I think j2me might be too minimal for Clojure

8:44 Cark: sooo there it is ... i have my first clojure program in production !

8:44 a license server for another program, i already talked about it

8:44 Chouser: Cark: nice!

8:44 Cark: i'm pretty happy =)

8:45 rhickey: Cark: congrats!

8:46 Cark: we tested it with 20 thousand simultaneous connections, looks like it will be good for a couple years

8:46 using nio

8:47 all of the ssl/nio stuff was done in clojure itself

8:47 actually everything was done in clojure

8:48 MikeSeth: i should start pushing this shop here off php and to clojure

8:49 Cark: what i didn't like (always easier to talk about the bad things) : spotty completion in emacs (not using slime)

8:49 also : multimethods didn't cut it for the all connection->sll connection->line connection->license connection thing

8:50 Chouser: Cark: because of flexibility or performance?

8:50 Cark: flexibility

8:51 m�hh how to explain this

8:52 i was missing something like call-next-method

8:52 i think that's the gist of it

8:52 Chouser: ah.

8:53 Cark: anyways, building anonymous functions and putting these in a map achieves the goal, so that was no big deal

8:54 rhickey: Cark: there is get-method

8:54 Chouser: there was some discussion of that, which resulted in a new feature, but I don't remember the specific ...

8:54 rhickey: ,(doc get-method)

8:54 clojurebot: "([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"

8:55 Chouser: then again, fn's in a map are likely faster, so if they serve the purpose then great.

8:56 Cark: right, i didn't see how get-method would be usefull, it was adding another field in my map

8:56 rhickey: while not a blind next-method, you could (get-method foo-method my-parent-dispatch-val)

8:56 chessguy_work: can a macro raise an error?

8:56 MikeSeth: rhickey: is it your estimate that clojure wont be available on mobile platforms any soon?

8:57 Chouser: ,(doseq x)

8:57 clojurebot: java.lang.IllegalArgumentException: doseq requires a vector for its binding

8:57 Chouser: chessguy_work: like that?

8:57 chessguy_work: yep :)

8:57 marklar: MikeSeth: You can write Android apps with it already

8:57 chessguy_work: so it's a compile-time error then

8:57 rhickey: MikeSeth: people are playing with it on Android now

8:57 Chouser: chessguy_work: sure. or the macro can emit code which throws the exception, and then you have a runtime error.

8:57 MikeSeth: mmmm delicious

8:58 marklar: MikeSeth: Check out http://github.com/remvee/clojurehelloandroid/tree/master

8:59 * Chouser struggles to write Java code while trying to demonstrate his Clojure lib's interop.

9:01 chessguy_work: how evil is it for a macro to evaulate some of the code passed t oit

9:01 Cark: chessguy_work : you mean using eval ?

9:02 chessguy_work: or just unquoting and applying a function

9:02 Cark: well that's one of the goals of macros

9:03 the doseq macro, it does evaluate the body

9:03 ,(doseq [i '(1 2)] (println i))

9:03 clojurebot: 1 2

9:03 Chouser: using 'eval' is hardly ever what you want, even in a macro

9:04 Cark: the println form gets evaluated

9:04 Chouser: Cark: yes, but not by using 'eval' in the macro.

9:04 Cark: right

9:04 chessguy_work: yeah, having done a lot of JS programming, i tend to read 'eval' as 'evil

9:04 ''

9:05 ,(expand-macro '(doseq [i '(1 2)] (println i))

9:05 clojurebot: EOF while reading

9:06 chessguy_work: ,(expand-macro '(doseq [i '(1 2)] (println i)))

9:06 clojurebot: java.lang.Exception: Unable to resolve symbol: expand-macro in this context

9:06 chessguy_work: bah, what the heck is it calle

9:06 svdm: macroexpand

9:06 chessguy_work: ,(macroexpand '(doseq [i '(1 2)] (println i)))

9:06 clojurebot: (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)))))

9:06 chessguy_work: eep

9:08 err

9:08 what did doseq evaluate there?

9:09 MikeSeth: rhickey: out of curiousity, has it ever occured to you that lispy languages need better code visualization during development?

9:09 (the question goes to everyone really)

9:09 Chouser: it didn't evaluate anything -- it inserted the (println i) expression into its output, so that it would be evaluated at runtime.

9:10 chessguy_work: that's what i thought

9:10 so the macro doesn't evaluate any of its parameters

9:10 do other macros?

9:12 rhickey: MikeSeth: both enclojure and IntelliJ's La Clojure have structure browsers, enclojure's also has multimethod grouping

9:12 jdz: chessguy_work: macros don't evaluate their parameters, by definition.

9:12 chessguy_work: like, they literally can't?

9:12 MikeSeth: last time i tried enclojure it was too broken :(

9:13 but that was a long time ago

9:13 jdz: chessguy_work: macro is just a function, which gets some clojure values in, and produces another clojure value.

9:13 chessguy_work: the values it gets in are not evaluated.

9:14 chessguy_work: as opposed to functions, which always receive their argumentns evaluated.

9:14 arguments even

9:14 Cark: but nothing prevents a macro evaluating its arguments

9:14 jdz: yes, one just has to remember when the macros are being executed, which is compile time, not runtime.

9:15 Chouser: chessguy_work: you can use 'eval' in a macro, but usually it's not the right way to solve the problem at hand.

9:15 chessguy_work: Chouser, is taht the only way to evaulate in a macro?

9:17 asbjxrn: MikeSeth what do you mean by code visualization?

9:23 Chousuke: chessguy_work: you can use ~ inside syntax-quote

9:23 or hm

9:24 chessguy_work: to unquote it, right?

9:24 Chousuke: I guess that doesn't actually evaluate them

9:24 chessguy_work: but then you could (let [foo ~foo] (foo 1 2)) right?

9:25 Chousuke: ,(let [foo 5] [`foo `(foo ~foo)])

9:25 clojurebot: [sandbox/foo (sandbox/foo 5)]

9:25 Cark: let'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

9:26 or actually to output the 3 println forms

9:26 Chousuke: but checking explicitly for an integer would prevent it from working with variables

9:26 Cark: one could say that the first argument is evaluated

9:26 Chouser: right, but (let [x 3] (unroll x (println "hello"))) wouldn't work.

9:26 Cark: you wouldn't unroll a variable number of times

9:27 that's part of this macro's api

9:27 Chousuke: right.

9:27 Cark: or specification

9:28 though that's some braindead macro right there =)

9:29 Chousuke: (defmacro unroll [times body] `(do ~@(replicate times body)))

9:29 does that work?

9:30 hm, I guess it needs the &

9:30 no, I get a nullpointer exception ;(

9:30 chessguy_work: d'oh

9:30 der suckage

9:31 surely that's a bug

9:31 Chousuke: in my macro perhaps

9:31 chessguy_work: err

9:32 sorry, a null pointer exception at compile time is a compiler bug, IMHO

9:32 Cark: (defmacro unroll [times & body]

9:32 `(do ~@(replicate times `(do ~@body))))

9:32 ugly =)

9:32 Chouser: ,(intern 'sandbox '#^{:macro true} unroll (fn [times body] `(do ~@(repeat times (cons `do body)))))

9:32 clojurebot: #'sandbox/unroll

9:32 Chouser: ,(unroll 3 (println "hi"))

9:32 clojurebot: "hi"

9:33 chessguy_work: although...i guess at this point, if you're evaluating things at compiletime, you've really got turing-complete compilation

9:33 Chouser: ,(unroll 3 (print "hi "))

9:33 clojurebot: "hi "

9:33 Chouser: hm.

9:33 chessguy_work: ,(macroexpand '(unroll 3 (println "hi")))

9:33 clojurebot: (do (do println "hi") (do println "hi") (do println "hi"))

9:33 Chouser: doh

9:34 chessguy_work: ,(do (do println "hi") (do println "hi") (do println "hi"))

9:34 clojurebot: "hi"

9:34 Chousuke: chessguy_work: yes

9:34 chessguy_work: ,(do (println "hi") (println "hi"))

9:34 clojurebot: hi hi

9:35 Chouser: ,(intern 'sandbox '#^{:macro true} unroll (fn [times body] `(do ~@(repeat times `(do ~body)))))

9:35 clojurebot: #'sandbox/unroll

9:35 Chouser: ,(unroll 3 (println "hi"))

9:35 clojurebot: hi hi hi

9:36 Chousuke: (defmacro unroll [times body] `(do ~@(repeat times body))) works too

9:36 * Chouser sighs

9:36 cddr: what's the equivalent of funcall?

9:36 * chessguy_work giggles

9:36 MikeSeth: asbjxrn: well, since lisp syntax is trivial, you do not *have* to write and edit code as plain text

9:36 Chouser: cddr: you don't need it. just put the variable in the first position.

9:37 cddr: ah

9:37 Chouser: cddr: lisp 1 ftw.

9:37 Cark: (defmacro unroll [times & body] `(do ~@(apply concat (replicate times body))))

9:37 that's better !

9:37 MikeSeth: asbjxrn: with some thought I suppose you can visualize code and relations between code parts as e.g. 2d graphs, 3d models and so on

9:40 cp2: Unspecified 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."

9:40 hmm

9:41 * chessguy_work returns to his c#

9:41 * chessguy_work sighs

9:43 Chouser: ,(intern *ns* '#^{:macro true} _defmacro (fn [n & a] `(intern *ns* '~(with-meta n {:macro true}) (fn ~@a))))

9:43 clojurebot: #'sandbox/_defmacro

9:43 Chousuke: cp2: I tested a proof of concept of that vulnerability :P

9:43 it worked pretty well ;(

9:44 cp2: yeah, so it seems

9:44 asbjxrn: MikeSeth: 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.

9:44 Chousuke: asbjxrn: perhaps you've never seen a good visualisation :)

9:45 MikeSeth: asbjxrn: 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

9:45 asbjxrn: That is entirely true, I never have :)

9:48 MikeSeth: 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.

9:49 MikeSeth: asbjxrn: without question. I'm just saying that original approaches could be superior

9:49 asbjxrn: When visualizing code in my head, it's more about abstractions and invariants than the tree as such.

9:52 Chousuke: with an image you could densely represent a much larger set of relations though.

9:52 so it might be good for getting an overview.

9:53 or quick code review: if it looks sensible, you probably don't need a redesign.

9:56 asbjxrn: Chousuke: 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:03 Chousuke: http://code.activestate.com/recipes/576766 D:

10:22 marklar: Is there a clojure way to write/read structs to/from a file? Or are we supposed to use the Java IO classes?

10:25 Chouser: you can print and read maps as text, if you want.

10:27 marklar: Chouser: In clojure? I've got it writing to a file using the Java IO, but was wondering if there is a cleaner way.

10:30 Chouser: ,(prn {:a 1 :b 2})

10:30 clojurebot: {:a 1, :b 2}

10:30 marklar: Chouser: thanks!

10:30 Chouser: you could write that to a file, and read it in again later

10:31 that's all I mean. It's very good for some scenarios, not so much for others.

10:31 marklar: Chouser: That was exactly what I was looking for I think, it prints to *out* right?

10:31 I just need something very simple

10:32 Chouser: Yep, use (binding [*out* file-stream-thing] (prn ...))

10:32 marklar: k, thanks again!

10:32 hoeck: marklar: you may want to use clojure.contrib.duck-streams/spit too

10:32 marklar: hoeck: I'll take a look, I need something very simple though so I think prn will work

10:32 thanks

10:33 hoeck: marklar: that's the simplest way of writing sth. to a file I can imagine :)

10:33 marklar: hoeck: then I'll definitely take a look :)

10:36 alrex021: How do I pronounce clojure? Is it like closure? :)

10:36 rhickey: alrex021: yes

10:36 alrex021: thx

11:18 Chouser: is the only way to compile from the command-line like: java -cp clojure.jar clojure.main -e "(compile 'my.thing)" ?

11:19 well, I guess it's sufficient.

11:20 rhickey: there is clojure.lang.Compile

11:21 Chouser: hmph. I was looking for that in main.clj

11:22 ok, thanks.

11:33 triddell: I see two main json libraries, danlarkin's and stuart sierra's in contrib... anyone know why someone might use one over the other?

11:33 danlarkin_: triddell: at this point I'd say probably go for stuart's

11:33 unless you see some compelling reason to use mine

11:34 liwp: has anyone seen the following on windows with slime:

11:34 16:19 <Chouser> ok, thanks.

11:34 16:25 *** svdm QUIT Read error: 104 (Connection reset by peer)

11:34 16:25 *** svdm JOIN

11:34 16:29 <triddell> I see two main json libraries, danlarkin's and

11:34 stuart sierra's in contrib... anyone know why

11:34 someone might use one over the other?

11:34 16:30 <danlarkin_> triddell: at this point I'd say probably go for

11:34 stuart's

11:34 > 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:34 urgh, sorry about that

11:34 AWizzArd: Is there a function (maybe in contrib) that allows me to ask yes/no questions as input from the keyboard?

11:35 liwp: 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:35 basically slime fails to run clojure and keeps polling until I abort it

11:36 triddell: danlarkin_: I saw he stated "If you want indented output, try the clojure-json library at http://github.com/danlarkin/clojure-json"... which would be nice, but I didn't know of any other major differences.

11:36 cp2: AWizzArd: dont think so

11:36 dnolen: liwp: are you using Clojure 1.0?

11:36 cp2: maybe you should make one!

11:36 and submit

11:36 to contrib

11:36 liwp: dnolen: svn HEAD

11:36 dnolen: liwp: using 1.0

11:37 er use i mean.

11:37 Chouser: AWizzArd: read-line is the closest thing I know of.

11:37 liwp: dnolen: 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:39 AWizzArd: Chouser: probably that's enough for me

11:39 danlarkin_: triddell: yeah they're very similar at this point. stuart's has the advantage of being in contrib, so one less dependency

11:41 triddell: danlarkin_: ok, thanks for the feedback

11:43 alrex021: I'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:45 liwp: dnolen: 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:47 marklar: liwp: i've been dealing with the same issue on a linux box, haven't been able to figure it out either :(

11:50 chessguy_work: ,(let [f (fn [x] (. Character isDigit x))] (f 5))

11:50 clojurebot: false

11:50 chessguy_work: ,(let [f (fn [x] (. Character isDigit x))] (f '5'))

11:50 clojurebot: Unmatched delimiter: )

11:50 AWizzArd: I 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:50 chessguy_work: ,(let [f (fn [x] (. Character isDigit x))] (f "5"))

11:50 clojurebot: java.lang.IllegalArgumentException: No matching method found: isDigit

11:52 chessguy_work: ,(let [f (fn [x] (. Character isDigit x))] (f \5))

11:52 clojurebot: true

11:53 cp2: marklar: marklar marklar, marklar marklar marklar!

11:55 marklar: cp2: I've always thought the same thing

11:55 cp2: heh

11:55 sorry, i just saw your name and it reminded me =)

11:55 marklar: cp2: np :)

11:59 chessguy_work: ,(\5)

11:59 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn

12:00 chessguy_work: ,\5

12:00 clojurebot: \5

12:01 AWizzArd: java -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:01 rhickey: AWizzArd: did you try that with latest trunk?

12:02 AWizzArd: no, I will do this right now

12:03 Cark: ,(doc defsymbolmacro)

12:03 clojurebot: java.lang.Exception: Unable to resolve var: defsymbolmacro in this context

12:04 Cark: there is a thread talking about symbol macros on the mailing list, is that from a library ?

12:06 ok found it in clojure contrib =)

12:06 now why would this be bad ?

12:12 Chousuke: what, defsymbolmacro?

12:13 cp2: 11:02 < Cark> ok found it in clojure contrib =)

12:13 Cark: symbol macros, rich is saying he's "a bit concerned by the need of symbol macros"

12:15 cp2: what is a symbol macro?

12:15 Cark: some kind of a macro that willl be expanded with just the symbol

12:16 like i could expand the symbol 'hello to (println "hello")

12:16 cp2: oh

12:16 hm

12:16 not sure i like that idea =\

12:17 Cark: that's a silly example, but there are cases where it would be usefull

12:17 cp2: yeah i can imagine

12:17 Chouser: CL has them?

12:17 Chousuke: yes

12:52 rhickey: any good tokyo cabinet libs for Clojure?

12:53 rsynnott: well, there's a java api...

12:54 rhickey: rsynnott: got that

12:55 rsynnott: it's a simple enough library in terms of interface provided that a wrapper might nearly be overkill

12:55 rhickey: a wrapper would let it work with all Clojure map and seq functions

12:55 clojurebot: map is *LAZY*

12:56 rsynnott: oh, I suppose so, yes

12:57 cddr: has anyone written a "clojure for cl programmers" tutorial?

12:58 danlarkin_: I have a couchdb library that I'm working on... but that's not tokyo cabinet...

13:01 Chouser: we're using tokyo cabinet, but not from clojure (yet)

13:01 technomancy: anyone using S3 from clojure?

13:01 Chouser: fascinating array of "no"s there.

13:02 technomancy: it looks like it's a simple matter of a bunch of rest calls, not really much room for a library to abstract things

13:03 rhickey: I wonder how well tokyo cabinet's threading/lock stuff plays with Java

13:03 technomancy: not tyrant, the cabinet directly embedded

13:04 how about jdbm?

13:11 danlarkin_: *crickets*

13:16 cddr: has anyone written a "clojure for cl programmers" tutorial?

13:16 sorry, didn't mean to report my earlier comment

13:17 technomancy: cddr: there's a video of a presentation rich gave to a Lisp group that would probably be helpful

13:17 it's not too specific to CL, but it addresses folks coming from a lispy background

13:22 AWizzArd: btw 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:22 Thanks for the hint :)

13:29 rhickey: cddr: not that I know of, I presume you've seen http://clojure.org/lisps

13:33 technomancy: oh snap; the oreilly scala book is free online

13:33 ... and the second word of the first chapter is "enterprise". didn't see _that_ coming. =)

15:01 triddell: rhickey: 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:02 sopel: hey

15:03 any idea how to cast a Clojure vector to a byte array so that i can write it to a java outputstream?

15:05 Chouser: vector of...? Integers?

15:05 sopel: yeah

15:05 Chouser: ,(into-array Byte/TYPE (map byte [1 2 3 4]))

15:05 clojurebot: #<byte[] [B@8ccbe7>

15:06 sopel: oh, thanks.

15:06 i'm working with sockets, it's pretty cumbersome.

15:08 durka42: hmm, SwingUtilities/invokeLater swallows exceptions doesn't it

15:13 Chouser: rhickey: What would you require of a Contributor's employer to be comfortable with patches originally owned by that employer?

15:13 a specific signed document with their name and yours?

15:13 a general written corporate policy that employees my submit patches to open source projects?

15:13 s/my/may/

15:14 rhickey: Chouser: should be a CA from employer

15:14 sopel: how to find the names of classes of base clojure datastructures? i want to derive them

15:15 for multimethod dispatching

15:15 Chouser: so the employer would then retain the copyright

15:15 ,(class {})

15:15 clojurebot: clojure.lang.PersistentArrayMap

15:15 Chouser: sopel: like that?

15:15 ,(class (hash-map))

15:15 sopel: :)

15:15 clojurebot: clojure.lang.PersistentArrayMap

15:15 Chouser: ,(class (hash-map :a 1))

15:15 clojurebot: clojure.lang.PersistentHashMap

15:15 rhickey: Chouser: yup

15:15 sopel: yea pretty simple. thanks. still learning.

15:15 Chouser: rhickey: ok, thanks.

15:15 rhickey: from the CA: "If this contribution is on behalf of a company, the term 'you' will also mean the

15:15 company you identify below"

15:16 Chouser: sopel: note that there are many specific derived types, and some important interface types.

15:16 rhickey: ooh, La Clojure adds a REPL!

15:16 sopel: ok.

15:17 mattrepl: after "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:17 noidi: is it possible to use ctags with clojure?

15:18 Chouser: rhickey: 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:18 sopel: Chouser; oh, LazilyPersistentVector alread ypopped up.

15:19 mattrepl: for 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:19 rhickey: Chouser: this has to be true:

15:19 With respect to your contribution, you represent that:

15:19 o it is an original work and that you can legally grant the rights set out in these terms;

15:20 danlarkin: mattrepl: c.c.json probably doesn't have a default dispatch for j.u.ArrayLists, you can add one with defmethod though

15:20 something: I'm trying to consume PersistentStructMap from jruby, not sure how to access the values in the map.

15:20 mattrepl: but 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:20 danlarkin: 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:21 rhickey: Chouser: so, depending on your policy/authorization, yup

15:22 sopel: hum, 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:22 rhickey: Chouser: I've gotta run soon, does that make sense?

15:22 Chouser: rhickey: well, I'm trying to help form the policy

15:22 I've never had so much fun. :-P

15:22 rhickey: fair enough :)

15:22 Chouser: yep, thanks.

15:22 danlarkin: mattrepl: curious...

15:23 rhickey: the Sun CA is certainly commercial friendly, they got Google and Red Hat to sign it. Contributors really give up nothing, just share

15:25 danlarkin: mattrepl: use parents/ancestors/descendants and isa? to query the hierarchy

15:25 after the use

15:26 mattrepl: danlarkin: did that, and didn't see modification as I would expect if print-json isn't dispatching correctly

15:29 danlarkin: mattrepl: after using I run: (ancestors java.util.Collection) and it returns #{:clojure.contrib.json.write/array java.lang.Iterable}

15:29 mattrepl: good, at least it's just me... one moment

15:31 yeah, I just restarted the session and I'm only seeing Iterable after the use. must be configuration error, thanks for sanity check

15:32 something: I 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:33 danlarkin: mattrepl: what version of clojure are you running?

15:33 mattrepl: it's post 1.0, I believe

15:34 marklar_: How does one checkout the 1.0 version of clojure from the googlecode page? I've never used svn before...

15:34 danlarkin: mattrepl: ok, just checking... I'm on latest SVN

15:38 hiredman: marklar_: I would just download the zip

15:39 marklar_: hiredman: I need to make some changes

15:39 hiredman: I am not 100% sure but I think the zip includes sources

15:40 danlarkin: marklar_: you can just use the path when you checkout... so it's whatever... svn co code.google.com/clojure/tags/1.0

15:40 marklar_: hiredman: you know, I think you're right

15:40 danlarkin: thanks, tags was what I was looking for

15:43 cemerick: argh, 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:44 hiredman: this does sound familar

15:45 cemerick: Rich 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:45 danlarkin: how about using the two-argument form of keyword?

15:46 cemerick: danlarkin: ech. There really is an elegant reader form that does it.

15:46 hiredman: 2009:Apr:30:05:14:01 rhickey : ::myns/foo

15:47 danlarkin: human google

15:47 hiredman: well, I have my personal logs here on disk so I can just grep

15:47 cemerick: hiredman and clojurebot are actually just skynet v0.9

15:49 danlarkin: speaking of, what the heck is this company thinking, naming themselves cyberdyne and building robots?!? http://www.cyberdyne.jp/english/index.html

15:49 cemerick: nice

15:50 p_l: danlarkin: afaik only exoskeletons for now

15:50 danlarkin: kara thrace harbinger of death

15:50 cemerick: that's like the old joke about Wang coming to America, and not understanding what all the snickering was about.

15:55 hiredman: clojurebot: functional programing?

15:55 clojurebot: Huh?

15:55 hiredman: clojurebot: functional programing is <reply>http://jackcoughonsoftware.blogspot.com/2009/05/teaching-functional-programming-to-kids.html

15:55 clojurebot: Ik begrijp

15:56 p_l: danlarkin: also, notice the name of the system...

15:56 danlarkin: "*Hybrid Assistive Limb*, and *HAL* are trademarks (TM) or registered trademarks (�) of CYBERDYNE, Inc."

15:56 danlarkin: HAL? yeah, they're so hip

15:57 downfall of humanity right here

15:57 p_l: Nah, they are only making simple stuff. Fear the AGI research :D

15:58 something: is there an opposite of the bean function?

15:59 hiredman: nope

15:59 because beans are class and to make new classes you need to AOT compile

15:59 well

15:59 beans are instances of classes

15:59 something: AOT?

16:00 hiredman: ahead of time

16:00 something: i see.

16:00 it seems like it's possible

16:01 hiredman: http://gist.github.com/34229 is a old (possibly not working) and lacking features (like types) macro for easily generating beans

16:02 of course you would still need a function to map a map to a bean

16:02 sopel: how to make map non-lazy?

16:02 hiredman: (doc doall)

16:02 clojurebot: "([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:02 hiredman: (doc dorun)

16:02 clojurebot: "([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:02 something: hiredman, cool thanks

16:03 sopel: i'm using str for debugging, any neater way to print datastructures?

16:03 'cause (str somevector) isn't giving me the contents ;)

16:03 hiredman: prn-str

16:04 ,(prn-str [1 2 3 4])

16:04 clojurebot: "[1 2 3 4]\n"

16:04 hiredman: ,(str [1 2 3 4])

16:04 clojurebot: "[1 2 3 4]"

16:05 sopel: thanks

16:11 HAppyKAmikaze: hello world

16:12 something: was that from clojure?

16:43 cemerick: mmm, the "new" enclojure release is yummy so far

16:44 mrsolo: why isn't cons lazy by default?

16:46 technomancy: mrsolo: there's some overhead to lazy sequences

16:49 mrsolo: i take it the performance hit is very noticeable?

16:49 technomancy: mrsolo: it _would_ be noticeable if you had to invoke it for every single cons call.

16:59 cemerick: I wonder...

16:59 ,(ref 5)

17:00 clojurebot: #<Ref@47dc79: 5>

17:00 cemerick: ,(ref 5 :meta {:foo 0})

17:00 clojurebot: #<Ref@11e7af3: 5>

17:00 cemerick: hrm, that throws a classcast for me...

17:01 durka42: works for me

17:03 cemerick: durka42: yeah, it's a sporadic error on my end. Not sure what to make of it.

17:44 twism: how do you check if a map contains a key?

17:44 danlarkin: (doc contains?)

17:44 clojurebot: "([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:45 twism: if anyone knows that off head... im too lazy to browse the api

17:45 thanks danlarkin

17:45 danlarkin: find-doc is your friend

17:46 hiredman: also, maps are Collections so they have a .contains method

17:46 ,(.contains {:a 1} 1)

17:46 clojurebot: java.lang.IllegalArgumentException: No matching method found: contains for class clojure.lang.PersistentArrayMap

17:46 twism: oh cool

17:46 hiredman: oh

17:46 wait

17:46 Maps are not Collections

17:46 duh

17:46 twism: lol

17:46 hiredman: everything else is

17:46 ,(.contains [1 2] 1)

17:46 clojurebot: true

17:47 hiredman: ,(.contains [0 2] 1)

17:47 clojurebot: false

17:47 twism: ,(contains? {:a 1} :a)

17:47 clojurebot: true

17:47 hiredman: ,({:a 1} :a)

17:47 clojurebot: 1

17:48 twism: thanks guys

17:48 #clojure is the best

17:48 hiredman: ,(.keySet {:a 1})

17:48 clojurebot: #< [:a]>

17:48 hiredman: ,((.keySet {:a 1}) :a)

17:48 clojurebot: java.lang.ClassCastException: clojure.lang.APersistentMap$2 cannot be cast to clojure.lang.IFn

17:48 hiredman: ,(get (.keySet {:a 1}) :a)

17:48 clojurebot: nil

17:49 hiredman: :(

17:53 twism: hiredman: isnt that right?

17:54 hiredman: ,(:a (.keySet {:a 1}))

17:54 clojurebot: nil

17:54 hiredman: ,(class (.keySet {:a 1}))

17:54 clojurebot: clojure.lang.APersistentMap$2

17:54 twism: ,(doc get)

17:54 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

17:54 hiredman: ,(get #{:a} :a)

17:54 clojurebot: :a

17:54 twism: hmm

17:54 hiredman: ,(map #(.getName %) (.getMethods (class (.keySet {:a 1}))))

17:54 clojurebot: ("contains" "size" "iterator" "hashCode" "equals" "removeAll" "add" "clear" "toString" "isEmpty" "addAll" "toArray" "toArray" "remove" "containsAll" "retainAll" "wait" "wait" "wait" "getClass" "notify" "notifyAll")

17:55 hiredman: ,(.contains (.keySet {:a 1}) :a)

17:55 clojurebot: true

17:55 hiredman: :(

17:58 http://farm3.static.flickr.com/2289/2126533900_30e4e1cd4f.jpg

18:25 danlarkin: if I'm conjing into an array-map, it should remain in the order the elements get conjed on, right?

18:29 hiredman: danlarkin: until it becomes a HashMap, I believe so

18:30 danlarkin: oh, I see... this must be becoming a hash-map somewhere then

18:30 hiredman: around 8 to 10 entries

18:31 danlarkin: oh, even if I instantiate with (array-map)? I thought that would force it to remain one

18:31 hiredman: ,(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:31 clojurebot: clojure.lang.PersistentHashMap

18:32 danlarkin: darn

18:32 I want an ordered map

18:32 rsynnott: funny, really, you rarely see ordered maps

18:32 clojurebot: The 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:33 hiredman: possibly a sorted set of keys?

18:33 rsynnott: I suppose they'd be a little expensive

18:33 hiredman: hey

18:33 yeah, you could attach a sorted set of keys as metadata

18:34 of course you would need to wrap conj and assoc, etc

18:34 danlarkin: yeah, no good

18:35 hiredman: I dunno that it is no good

18:35 you just shove it in to d.lakin.sorted-map

18:35 exclude the core versions

18:36 (:require [d.larkin.sorted-map :as sm])

18:36 sm/assoc etc etc

18:36 danlarkin: :-/

18:37 that's too much

18:38 it's a library, I can't really make people use dan.larkin.ordered-map/get for one map returned by one function

18:38 I wouldn't want to, even

18:46 hlship: working on a macro to define a function in another namespace

18:46 so as to have access to that namespace's private defs

18:46 context: using Clojure as a property expression language inside a template file (for cascade)

18:46 http://paste.lisp.org/display/80573

18:47 doesn't seem to work, however

18:47 user=> (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:47 It's as if the (in-ns) doesn't work.

18:48 technomancy: wasn't there a "with-ns" added that temporarily changes the namespace?

18:48 hiredman: hlship: the namespace that def uses is determined durring compile time

18:48 so you need to use intern

18:48 (doc intern)

18:48 clojurebot: "([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:52 hlship: thanks for the tip, but I'm not seeing what exactly should be "intern"-ed

18:53 hiredman: hlship: the function

18:53 hlship: So, use (intern) rather than (defn)?

18:54 hiredman: some like (intern (create-ns "some.namespace") (fn [] "foo"))

18:54 ,(doc create-ns)

18:54 clojurebot: "([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:55 hlship: can 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:55 hiredman: lemma take a look at your paste

18:57 hlship: so you are passing in something like (defn foo [] "foo") ?

19:01 because intern explicitly takes a namespace argument you wouldn't have to deal with in-ns back and forth

19:11 mrsolo: hm clojurecheck, does it work?

19:20 Chousuke: hiredman: you can use find-ns :p

19:21 hiredman: Chousuke: sure sure

19:22 but create-ns acts just like find-ns, but it will create the ns if it does not exist

19:22 mrsolo: oh. well quickcheck aspet isn't implemented yet..

19:54 _hrrld: I'm trying to use print and read to serialize a vector of strings and I'm getting owned:

19:54 (with-in-str (with-out-str (print ["a b c" "d e f"])) (read))

19:55 durka42: ,(pr-str ["a b c" "d e f"])

19:55 clojurebot: "[\"a b c\" \"d e f\"]"

19:55 durka42: ,(read-string (pr-str ["a b c" "d e f"]))

19:55 clojurebot: ["a b c" "d e f"]

19:56 _hrrld: n1, thanks.

20:01 mrsolo: I am seeing something like this in core.clj.. what does it mean? [#^clojure.lang.IObj x m]

20:01 type casting?

20:01 ataggart: type hint i think

20:02 to avoid reflection

20:02 mrsolo: ah thanks

20:03 another question. what is (fn* ....)?

20:03 (fn* let [& decl] (cons 'let* decl))) for example

20:04 ataggart: dunno

20:04 I dont see it being declared in any of the clj

20:04 mrsolo: core.clj

20:05 being used that is

20:05 ataggart: ya, I means fn* itself being declared. Given how high it is in clore.clj, I'd imagine it's in the java side

20:05 in the processing

20:06 erm.. reading

20:06 just a guess tho

20:07 ya, check out Compiler.java

20:07 it's a symbol created amongst all th eother special forms

20:09 mrsolo: oic.. thx

20:59 beelee: ,(-> 2 (fn [x] (+ 1 x)))

20:59 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

21:00 beelee: but if i bind that fn to something it works?

21:03 ,(let [f (fn [x] (+ 1 x))] (-> 2 f))

21:03 clojurebot: 3

21:04 dysinger: ,(System/exit 1)

21:04 clojurebot: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)

21:04 dysinger: :)

21:05 durka42: beelee: -> is translating the first form into (fn 2 [x] (+ 1 x))

21:06 ,(-> 2 ((fn [x] (+ 1 x))))

21:06 clojurebot: 3

21:06 beelee: hmm, i see what you mean

22:47 danlarkin: rhickey: any thoughts on adding an ordered-map to clojure? I have a use case that requires one

22:56 rhickey: danlarkin: there is a sorted map

22:57 danlarkin: I want to sort by insertion order

22:59 rhickey: then it's going to be a slow map

22:59 might as well just search for things in a vector

23:30 sshack: quick question. what do the []'s do?

23:31 hiredman: vector literal

23:31 ,(class [])

23:31 clojurebot: clojure.lang.PersistentVector

23:31 sshack: ahh. Okay, I see now.

Logging service provided by n01se.net