#clojure log - Nov 19 2008

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

0:59 arohner: how do I pass a java static method to map?

1:00 (map Integer/parseInt my_seq) does not work

1:00 abrooks: arohner: IIRC, I had to add a fn/#() wrapper.

1:01 arohner: there's memfn, but that appears to only work on instance methods

1:02 abrooks: I used something like this before: (map #(Integer/parseInt %) ["2" "3" "4"])

1:03 I do consider it a bug to have to wrap it though.

1:03 arohner: yeah, that's what i came up with, and I assumed there was a better way

1:04 abrooks: Not that I recall.

1:04 arohner: thanks

1:57 wlr: arohner: Class/staticmethod is a macro not a function. Macros (I believe) only get expanded in the operator position of a sexp. Wrapping puts it into operator position.

2:47 skrit: Anybody get tab completion working with clojure+slime? I get "Symbol's function definition is void: slime-fuzzy-complete-symbol"

3:21 Pupeno: Good morning.

3:28 blarf: how can i change co C-c C-l only loads the current file into the itnerpreter and doesnt switch the current window to the interpreter as well?

3:41 and is it possible to make error-messages clickable in emacs, i mena it must be because it is in other modes?

3:43 Pupeno: blarf: won't C-c C-k do that?

3:48 blarf: undefined, not using slime, just clojure-.mode

3:51 Pupeno: blarf: oh! sorry.

4:08 blarf: ahhh clojure is such a nice lisp. i havent used scheme or common lisp THAT much but clojure is so nice to work with. and while haskell is very cool clojure is a lot more practical.

4:15 Pupeno: blarf: 100% agreed!

4:40 blarf: i have an if-else where i want to conj to a vector if but when else i dont want to do antyhing

4:40 wait when!

4:40 niot if!

4:42 or not

4:48 if i reduce with "when " does every elem has to conj something?

4:48 that cant make much sense hmm. i get nullpointerexception when using reduce+when, could it be becaus eof the when-not cases?

4:49 yes it seems so.

4:49 because it works with another cond

4:50 so lets say i want to accumulate + filter, how would i do that? take element if cond and increase the last elem else nothing

4:50 is what iw ant to do

5:02 lisppaste8: blarf pasted "gen-valid-indexes" at http://paste.lisp.org/display/70707

5:02 Chousuke: blarf: hm, if I understand you correctly you might just be able to do (if condition (conj foo bar) foo), right?

5:02 blarf: ^^

5:02 i have a big loop-recur that works, im just looking for a more elegant version

5:07 wait if i do distinct on yourt solution it might work

5:07 Chousuke: so wait, you want to filter out nils in the coll?

5:10 blarf: it is a tic-tac-toe board so it will be given something like: [0 0 1 0 0 9 0 1 9] where 0s are available moves and 1 and 9 are taken

5:10 i want to get back available moves, so in this case: [0 1 3 4 6]

5:14 Chousuke: the indexes for all that are zero?

5:14 (map first (filter #(= 0 (second %)) (partition 2 (interleave (iterate inc 0) coll)))))

5:15 you need to read that starting from the end. :)

5:19 blarf: did you get my solution?

5:19 blarf: i was disconnected did you post anything?

5:19 i have a solution just annoyin g i cant find a more elegant one

5:19 Chousuke: okay

5:19 I got an oneliner :)

5:19 lisppaste8: Chousuke annotated #70707 with "one-liner" at http://paste.lisp.org/display/70707#1

5:22 Chousuke: = 0 can be replaced with zero? too. looks nice that way

5:22 nicer*

5:24 but it seems you were trying to use reduce for something it's not suitable for.

5:24 you generally want to use it when you need to reduce a collection into a single item

5:30 blarf: yes you are right

5:48 what vecrsion control system do you use? git? i have neevr used one for real, i just use git, cvs, darcs etc to pull libs and stuff.

5:48 can i integrate git with emacs somehow?

5:48 i should go --> git

5:56 tWip: If you plan to support all platforms then subversion is a safe bet

5:57 I don't know if git is well supported on windows/mac yet

5:57 and by support I mean if you have developers using those platforms

6:28 Chousuke: no problem with git on mac

6:28 windows support is still a bit problematic

6:35 I have to say that after getting used to git working with SVN just annoys me :/

6:35 tWip: I better not start using git then... can't escape SVN at work ;)

6:36 Chousuke: fortunately git can act as a rather nice SVN client

6:37 the initial checkout with git svn is horribly slow (it checks out every possible revision from the SVN repo) but after that it's pretty much like any git repo.

6:39 tWip: sweet

7:00 blarf: anyone know of a good java-lib for opening and playing mp3s and other audio files?

7:40 i have a weird profiling problem (kudos btw to how easy it is to time executon-time)). i have 2 gen-all-valids funcs, one loop-recur by me which executes in 240ms and retuns the answer immediately. then i have Chousukes more elegant version that ha a much shorter execution-time according to (time) but the answer isnt delivered immediately. how could that be?

7:41 also, would it be easy to write a more general profiler? that could return the results eparately for several functions? i might do one in that case

7:41 rhickey: blarf: you can use Java profilers, which are abundant and quite good

7:41 blarf: if i do (time (f1 (f2 y))), then time times the total right? or could my problem above be because of 2 functions in one? where one is equal and the other isnt

7:42 rhickey: time is for the entire expression, but if it returns something lazy, not all the work has been done

7:57 blarf: i see

8:07 blackdog_: what's the function that does a let if a key is in a hash - been looking for 5 mins now, know it's here somewhere :)

8:08 rhickey: blackdog_: unclear to me what you mean, a let can't be done by a function - do you mean destructuring of maps in let?

8:09 blackdog_: it's like an if-let but on a key, if key is in collection assign the value

8:09 rhickey: blackdog_: otherwise what?

8:09 blackdog_: nil i think

8:10 sorry rhichey don't want to bother you with stupid stuff i'll keep looking, I've used it befire

8:14 duh, when-let i thought it was special for hashes

8:14 sorry for noise

8:22 duck1123: blarf: if you're still looking for git+emacs, look for a package called Magit. It's very nice

8:22 Chouser: rhickey: can we break doto soon?

8:24 rhickey: Chouser: I saw you'd asked about that - I guess we should, but I'm getting tired of getting beaten up for breaking things...

8:24 Chouser: rhickey: hehe. ok, I just wanted to remind you of the thread.

8:25 rhickey: I'm ok with using my own doto->

8:25 rhickey: Chouser: is there a patch?

8:26 Chouser: there's a macro at the top of the thread.

8:26 I'd be happy to prepare a real patch if that helps.

8:26 duck1123: If you're going to break things, it's better to break them early rather than doing it down the road

8:27 blackdog_: yea, anything goes pre 1 IMO better to get it right

8:27 Chouser: I'm sorry I didn't remember we wanted to break doto when we broke the binding macros.

8:29 gnuvince: Good day

8:29 duck1123: all told, it took me about 1/2 hour to adapt to all of the breaking changes, and that was only because I was doing it over SSH.

8:30 tWip: agreed, fixing this sooner rather than later is good

8:30 blackdog_: yea, the last changes weren't too arduous

8:30 tWip: and I don't mind migrating code if the changes are good

8:32 duck1123: does anyone know if anything needs to be done to adapt to the new changes to swank-clojure? I saw there were a lot of changes today, but haven't pulled yet

8:33 mehrheit: duck1123: if you are using the latest clojure svn, probably not

8:34 duck1123: afaik the configuration hasn't changed

8:35 duck1123: It's high time I clean up my clojure-elisp code anyway

8:40 mehrheit: rhickey: would it be sensible for isa? to return true for sets, where child is a subset of parent?

8:41 that would allow to define methods based on a struct's/map's keys with a dispatch-fn of (comp set keys)

8:44 Chousuke: blarf: you can time my lazy version with (time (doall (my-function)))

8:45 Chouser: rhickey: http://clojure.googlegroups.com/web/better-doto.patch -- in case that helps at all

8:50 Chousuke: blarf: it seems your looping version is much faster :)

8:52 and my version runs out of java heap space with a million items. Laziness has its drawbacks. :P

8:57 blarf: if i have a function that returns a function, how can ir eturn the respresentation of the function?

8:58 Chousuke: blarf: so how much did you miss this time? :P

8:58 you really need a better connection

8:58 blarf: I did some testing, and your looping version is much faster. Mine also seems to use all of java's heap space with a million items.

8:59 I guess that's the price to pay for elegance ;(

8:59 duck1123: why don't we have a link to the logs in the topic?

9:01 rhickey: mehrheit: I don't think a subset isa set

9:04 Chousuke: it'd allow some neat duck typing -style dispatching though. :/

9:06 blarf: Chosuke: i see, thanks

9:07 Kerris0: hmm I should d/l the latest Clojure book update-release

9:07 wonder what's been added

9:08 rhickey: Chouser: thanks - does that patch fix all uses of doto in the core libs, if any?

9:09 Chousuke: guess you could define a vector of sets and then just use something like #(find-first (map #(subset? val %) sets)) as your dispatch function

9:10 MarkVolkmann: I thought I knew how to use (find-doc ...), but I can't get it to work this morning. Can someone show me an example of the syntax for using it?

9:10 rhickey: MarkVolkmann: it just takes a string, which can be a regex

9:12 MarkVolkmann: How can I find all the methods that end in a question mark? (find-doc "?$") and (find-doc "\?$") don't work.

9:12 Chousuke: ".*\?$" ?

9:13 hm, apparently escaping ? doesn't work.

9:14 blarf: (find-doc "coll") does

9:14 nah icould get \? to work

9:15 MarkVolkmann: (find-doc "\?") gives "Unsupported escape character: \?" using the latest version from svn this morning.

9:16 Chousuke: gm

9:16 you need to double the escape \

9:16 (find-doc ".*\\?$") works

9:17 doesn't even need the .* after all, apparently

9:17 blarf: if i have: user=> f

9:17 user.fn__2578@c38157

9:17 how cna i get the list-representation of f?

9:17 Chousuke: blarf: you can't

9:17 blarf: so id have to store a rep together with it then

9:18 Chouser: rhickey: no. inspector uses doto. I'll fix it.

9:26 blarf: just wondering, i thought lisp meant having access to the AST but that is only through macros? i mean storing a list or string representation of a function isnt too bad but justn being able to do (list-rep f) would be cool. (im doing simple genetic programming)

9:27 Chousuke: there's no AST :p the code is the AST.

9:27 blarf: aha

9:28 mehrheit: blarf: you can define a macro, which, in addition to defining a function, saves it's representation into the functions metadata field

9:28 s/funtions/function's

9:29 Chousuke: hmm

9:29 ignas: hi

9:29 mehrheit: rhickey: ok, how about a way to specify an optional replacement for isa? for separate multimethods, like one can specify dispatch functions?

9:30 blarf: there is no haskell-like "data" right? what do you do when youd normally need a "data" or a class? like it is sometimes easier to graps if you have : data fun = fun { f, rep} rather than {f f-ref, r f-rep}

9:30 mehrheit: would that be too much freedom?

9:30 rhickey: mehrheit: the problem there is caching, we discussed before

9:30 blarf: mehrheit: ok how do i egt that rep later then?

9:31 mehrheit: rhickey: oh, it must be more complicated than i thought

9:31 blarf: with meta

9:32 blarf: Caused by: java.lang.Exception: Can't take value of a macro: #'user/sq

9:32 (meta sq)

9:32 ignas: i am trying to use clbuild slime + clojure-swank but keep getting resource not on classpath errors, is there some know way to fix this problem?

9:32 mehrheit: ignas: isn't clbuild for common-lisp?

9:33 Chousuke: blarf: mehrheit meant defining a macro that defines functions and saves their form in metadata.

9:33 ignas: mehrheit: yes, but it also can download cvs slime

9:33 I have tried doing (load "/swank.clj") but it fails when trying to find swank/core/core.clj

9:33 even though i have added that to the classpath :/

9:33 (that's without any emacs or slime involved)

9:33 blarf: Chou: ah i see

9:34 mehrheit: ignas: are you using swank-clojure from git?

9:34 ignas: yep

9:35 mehrheit: then you should use the latest clojure from svn

9:35 ignas: hmm, now i see one of the possible causes, it is trying to load "swank/core/core.clj"

9:35 while there is "swank/core.clj" in there

9:35 ok

9:36 going to get an svn clojure

9:38 blarf: there is no haskell-like "data" right? what do you do when youd normally need a "data" or a class? hash-maps for everything?

9:38 mattrepl: struct-maps, but those are just optimized hash-maps that carry minimal semantics to the user

9:40 ignas: mehrheit: thanks, that helped

9:44 blarf: clojure/struct-map

9:44 ([s & inits])

9:44 i dont get how to call it

9:45 Chouser: blarf: http://en.wikibooks.org/w/index.php?title=Clojure_Programming#Structures

9:49 rhickey: http://clojure.googlegroups.com/web/better-doto-and-inspector.patch

9:50 and what's cool is, if I had done an "ant clean", I would have had a compile-time error about the incorrect usage in inspector.clj

9:52 drewr: Pretty interesting: http://is.gd/87Fr/click-moon-weinreb/

9:52 I don't understand most of it though.

9:58 Chousuke: hm

9:58 blarf: anyone good with emacs and emacs-modes? how do i add another coloring to certain keywords? i found where to add more keywords but what if i want another color than the defualt(purple) for osme of them?

9:59 Chousuke: what's wrong with the following: (def x 1) (with-meta x (assoc ^x :x 1)) ?

9:59 I get an exception

10:01 cooldude127: Chousuke: ^x is nill

10:01 *nil

10:01 and even so, i don't think numbers can have meta data

10:01 rhickey: and with-meta only works with symbols and collections

10:07 blarf: how can i list [ ?

10:08 cooldude127: blarf: what do you mean?

10:16 blarf: cooldude: ill post

10:17 cooldude127: k

10:19 rhickey: Chouser: patch applied - thanks!

10:20 blarf: http://paste.lisp.org/display/70716#1

10:21 Chouser: rhickey: great, thanks. shall I write up a notice for the group?

10:22 cooldude127: blarf: what's rand-func?

10:22 blarf: ^^ trying to create a macro that returns a struct that has the function as one field and its rperesentation as another

10:23 it will be more general later but i start simple

10:23 Chousuke: why a struct?

10:24 a map will do.

10:24 struct-maps are just maps anyway

10:24 cooldude127: blarf: the error is cuz you're trying to do (list (fn ...

10:24 maybe

10:24 blarf: well it doest have to be, what is better?

10:25 cooldude127: idk i'm quite confused

10:29 blarf: something like this maybe?

10:29 (defmacro fnrep [& rest] `[(fn ~@rest) '(fn ~@rest)])

10:30 does a vector with the first being a function, and the second being the code to create the function

10:30 could probably use a map too

10:33 Chousuke: Functions allow you to attach arbitrary metadata to them, so you can do something like (defmacro defn-with-form [name & form] `(defn ~name {:form '~`(defn ~name ~@form)} ~@form))

10:33 rhickey: Chouser: I put a note up on the group

10:33 Chousuke: then access that with (defmacro get-form [fn] `(:form (meta (var ~fn))))

10:34 cooldude127: Chousuke: that's much cooler in my opinion

10:34 Chouser: rhickey: ok, I saw that. thanks again. You can send any whiners my well -- I'll do my best to console them.

10:34 Chousuke: that has the problem that it doesn't work with overloading function, or doctrings.

10:34 Chouser: s/well/way/

10:34 cooldude127: you could write it too tho

10:34 Chousuke: you'll need to make the macro somewhat more complex to support them :P

10:35 meh

10:36 blarf: you *really* need to get a new connection.

10:36 abrooks: drewr: Heh -- SiCortex (where I work) is mentioned in the Cliff Click article you posted.

10:38 drewr: abrooks: Totally missed that!

10:38 abrooks: ;-)

10:39 drewr: It's an interesting article. We've got some ex-Symbolics guys here.

10:40 drewr: I got to experience Weinreb in person at OOPSLA. Interesting guy.

10:41 abrooks: drewr: The whole discussion was very interesting. Those sorts of details are where we live here at SiCortex. Azul and SiCortex have different target markets but we share a lot of similar design issues.

10:41 drewr: Cool.

10:41 drewr: It's fascinating stuff.

10:42 blarf: what does ~@ do ? is that one or two symbols btw? what is gensym again?

10:45 Chousuke: blarf: ~@ splices a seq into another

10:45 mattrepl: blarf: gensym is guaranteed to return a unique symbol

10:47 Chousuke: blarf: so for example if foo = (1 2 3), then `(1 ~@foo 3) = (1 1 2 3 3)

11:02 blarf: if i have an expensive function (f x) on three places and replace it with a let y (f x) , will that be faster or will clojure optimize away such things anyway?

11:03 cooldude127: blarf: i believe that will be faster

11:03 rhickey: blarf: let will be faster

11:03 mehrheit: blarf: clojure can't optimize such things away, since it can't know if functions are pure

11:03 rhickey: right

11:03 cooldude127: mehrheit: you said what i was about to

11:03 haskell could optimize that tho

11:27 cemerick: wow, 92 people in the channel

11:27 rzezeski: there were 100 a day or two ago

11:27 for a brief moment

11:28 blarf: can i only use @ in macros?

11:28 abrooks: what kind of software do you write?

11:28 anyone here work with imagesearch/facerecognition or machine learning?

11:28 cemerick: That's amazing. We were idling @ 35 or so over the summer.

11:33 Chousuke: blarf: ~@ only works in syntax-quoted forms, but you don't have to use those in macros :)

11:43 abrooks: blarf: Uh, all kinds. :) For work currently: kernel code / drivers, in-house automation/infrastructure, system management software for the product, etc.. My background is intelligent systems. I've written image recognition and machine based music transcription programs.

11:55 blarf: abrooks: very cool, im getting into machine learning and image recog, but have to finish high school first :)

12:03 is webjure or compojure the main web framework?

12:04 Chouser: blarf: I've not yet used either. compojure seems to have the momentum at the momeny, but I wouldn't write off webjure yet.

12:04 at the moment

12:06 blackdog: how is clojurescript Chouser ?

12:07 Chouser: blackdog: I've got it fixed up for post-AOT, but have been distracted by other things.

12:08 next step is a browser repl, which is pretty close to working.

12:08 blackdog: it's a lot of work, i'm not suprised, but you were making great progress

12:08 cool

12:11 Chouser: blackdog: thanks for expressing interest. Even that little bit is motivating. :-)

12:13 blackdog: :) i keep thinking it'd be more useful to use clojurescript as a json renderer on the client rather than the web frameworks which seem a bit dated

12:13 * blackdog ducks

12:14 blarf: wow, this is pretty neat: http://pacific.mpi-cbg.de/wiki/index.php/Clojure_Scripting

12:15 thanks whoever did that exactly what i was looking for to get started

12:20 clojurescript is what, like javascript?

12:20 i mean, meant to be able to extend the browser?

12:20 Chouser: blarf: clojurescript is a subset of clojure that can be compiled to javascript

12:21 so yes, it could be used for ajax, to write firefox add-ons, etc.

12:21 Chousuke: basically clojure without java compatibility stuff?

12:21 or is there something else missing as well?

12:22 blarf: wow, thats very cool

12:22 Chouser: well it uses the same sorts of forms to interop with js that clojure uses for java.

12:22 blackdog: and it integrates nicely with your favorite ajax framwork, jquery etc

12:22 Chousuke: heh

12:23 sounds really interesting.

12:23 Chouser: I mostly need to write up a couple examples, get it hosted somewhere other than on my home server, and then announce it.

12:24 Chousuke: javascript is quite important nowadays too. Is clojure trying to take over the world?

12:24 Chouser: it's complete enough to be useful, though I'd still like to add Refs, SortedSet, SortedMap, and a few other classes like that.

12:25 Chousuke: I don't want to have to use any other language, do you. ;-)

12:25 Chousuke: heh

12:26 is clojurescript AOT compiled to javascript?

12:26 or at runtime? or both?

12:26 blackdog: aot to javascript

12:27 Chouser: it's just a couple of functions -- pass in clojure forms and they return javascript strings

12:30 blarf: isnt javascript kind of scheme with curly brackets?

12:31 Chouser: blarf: yeah, having closures made some forms much easier to compile compared to what Rich had to do to get Java to work.

12:34 cooldude127: what's so great about javascript? idk i just don't really see the appeal

12:35 maybe i've done too much in the browser, idk

12:35 Chouser: cooldude127: if you don't need javascript, then clojurescript won't be interesting to you.

12:35 cooldude127: oh i know

12:35 i'm wondering about just plain javascript

12:35 Chouser: But if you have to write code in a context where javascript is available but java is not, perhaps clojurescript could help.

12:36 oh, I see.

12:36 cooldude127: i was getting somewhat off topic

12:36 Chousuke: Chouser: you might just be able to use the google thing that compiles java to javascript :P

12:37 Chouser: Chousuke: yeah, I looked at that. gwt. I couldn't get it to do what I needed.

12:37 part of the problem is that it compiles java source, not .class files, to js.

12:38 blackdog: Chouser, i see clojurescript is in rhickey long range plans on his todo

12:39 what size did you get the runtime downto?

12:42 Chouser: blackdog: haven't made any progress on that since last we talked.

12:42 blackdog: it was good anyway as far as i remember

12:43 Chouser: on the order of 20KB

12:43 as I add more Clojure classes that could increase, but there's also some tricks that could be used to reduce the size if it doesn't hurt runtime performance too much.

13:04 blarf: i have contrib in c:/clojure/contrib/, how can i link to it from user.clj?

13:07 Chouser: blarf: add c:/clojure/contrib/src to your java classpath, then use 'require' or 'use' in your .clj

13:37 AWizzArd: Moin Kota

13:37 kotarak: Hi wizz

13:41 duck1123: I would like to see ClojureScript + MozRepl, have you tried that yet?

13:44 AWizzArd: What are good reasons in your opinion to not do commercial projects in Clojure? Let's say about 15k to 25k LOC.

13:45 Chouser: duck1123: interesting. But no, I haven't look into MozRepl

13:45 Pupeno: Hello.

13:45 AWizzArd: I mean, right now, starting next week. Not in general.

13:47 Chouser: AWizzArd: biggest think i can think of is relative derth of resources on best practices for design of large scale systems in Clojure.

13:48 you might get some milage out of looking into CLOS resources, and of course asking questions on the group, but you won't find bookshelves full of material like you do for Java.

13:49 albino: Isn't language change an obstacle to?

13:49 AWizzArd: So you mean people could not understand how to do bigger projects in mostly functional programming style?

13:50 albino: Don't know if rhickey has made any claims about when the language will stop changing

13:50 Chouser: albino: I don't think that's a big deal. Breaking changes are rare (excluding the last couple weeks).

13:50 AWizzArd: well yes, this kind of instability is not so nice, but you are far better off when you have 15k LOC that work with Clojure 1.1 and just need to apply fixes for Clojure 1.5 instead of having nothing and need to write everything from scratch.

13:51 Chouser: and the recent breaking changes have been fairly superficial -- move around a couple files, do some search/replace and you're back up and running.

13:52 AWizzArd: I could not see what coming changes for the time ahead are needed/wanted that would break running code.

13:52 Chouser: AWizzArd: right. I mean, I could read through a few OO patterns books and be pretty confidant about the Accept Way to model any particular problem space in Java.

13:52 AWizzArd: but in Clojure, I feel less confident, and am not sure how to learn what I need to without just doing it and seeing what works and what doesn't.

13:53 AWizzArd: One problem that I see is that some bosses could be scared about if they can easily get more devs.

13:53 Chouser: This is a fine approach (and even fun and exciting) for 1K or 2K LOC projects, but if you bump that up an order of magnitude, you don't want to have to redesign core subsystems half-way through.

13:54 AWizzArd: yeah, but I'd say those bosses are largely incorrect. Every codebase I've ever worked on has internal APIs and features that make them each almost their own language.

13:54 AWizzArd: So, while you see this as one counter-argument, would you still consider writing commercial apps in a team of 5 devs? Or do you personally think that any company should wait 1-5 years?

13:54 Chouser: agreed

13:54 Chouser: No reason a new programmer who already knows Java or Lisp or even Ruby couldn't be brought up to speed on a Clojure codebase quickly enough.

13:55 blackdog: or javascript

13:55 Chouser: blackdog: :-P

13:56 blackdog: knowing javascript helped me understand clojure more than anything else

13:56 duck1123: does it make sense to measure lisp code length in LOC?

13:56 Chouser: oh, I see. Yea, I agree.

13:56 duck1123: it doesn't make sense to measure any code in LOC.

13:56 except in the vaguest of terms.

13:58 AWizzArd: duck1123: you could measure the size (in bytes) of the compiled .class files. This factors out the coding style of the lisp family

13:58 The tons of leading whitespace I mean.

13:58 the compiler can be seen as some kind of compression tool for source code

13:59 abrooks: duck1123: New software metric: NoP (Number of Parens)

13:59 AWizzArd: the more the better :-)

13:59 cooldude127: lol

14:00 Chousuke: you could cheat by writing all your code using vectors and providing an eval for that. :/

14:01 AWizzArd: So Chouser, would you do commercial development with Clojure today, even though you see some potential objections? In a team of, say, 5 devs? Or would you prefer to wait 2 or 5 years before this becomes a real option?

14:05 blackdog: AWizzArd, you're LOC in clojure will drop by at least half compared with java imo, so you need only 2 devs, which may be good in the current climate :)

14:06 AWizzArd: blackdog: I am comparing with an existing Lisp project

14:06 blackdog: oh ok

14:13 duck1123: I always feel most productive when at the end of a session my LOC goes down

14:15 AWizzArd: You could easily accomplish this by deleting your source files.

14:15 duck1123: I meant with no loss of functionality

14:16 AWizzArd: You could reformat your code so that it fits into one line

14:16 abrooks: Join separate statments with semi-colons?

14:16 AWizzArd: :)

14:18 duck1123: I would like to see a study about the amount of time the average programmer spends formatting their code to their liking

14:19 AWizzArd: probably small today, as the IDE can do this automatically for you

14:19 Chouser: AWizzArd: I think I would go ahead, even today. The one non-clojure project I'm involved with right now has a large C++ code base and no JVM in site.

14:20 duck1123: I've noticed I spend a lot of time trying to decide where I want to insert line breaks for the best asthetic effect

14:20 but perhaps I'm just a bit too OCD in areas like that

14:21 Chouser: I'd love to move that to Clojure eventually, but the existing code base plus different deployment profile required by a JVM raises the bar a bit.

14:21 for a new project or one already using JVM, I can't think of enough reasons to wait to outweigh the benefits of using Clojure now.

14:22 AWizzArd: I don't know that I count as an unbiased observer, though. :-)

14:23 AWizzArd: *g*

14:24 duck1123: wasn't there a page that showed how to call clojure code from java??

14:24 I can't seem to find it anymore

14:24 nvm, found it

14:25 Chouser: one key thought is that on a new project you have to decide very early how you're going to handle multi-threading: ignore it (assume you app will forever be essentially singel threaded), do it the classic way (deciding on your locking strategy, document how thread-safe each methoed is, etc.) or do it the Clojure way.

14:29 Time from reporting of weird Boolean bug until the bug was fixed: 1 hour 9 minutes.

14:29 rhickey: Chouser: includes lunch

14:29 AWizzArd: nice

14:30 * Chouser laughs aloud

14:30 * AWizzArd is collecting some arguments

14:31 blarf: bad codes codebase grow exponentially, good coers codebase nlogn-ish?

14:31 coders

14:32 rhickey: To Chouser's arguments pro-Clojure I'd add that while there isn't a body of advice on large projects in Clojure, Clojure was born of experience and frustration with difficulties found in large c++/c#/java projects, esp. as regards mutable state, independent of and in conjunction with concurrency

14:33 large application-specific class libraries of dubious abstractions

14:33 AWizzArd: this last point, about mutable state is also true for nearly all languages

14:33 rhickey: squirreling away generic data in useless specific objects

14:33 AWizzArd: like Ruby, CL or Delphi

14:34 rhickey: AWizzArd: true, my experience is the former but they all have pretty much the same model

14:34 AWizzArd: Clojure, Erlang and Haskell are one of the true exceptions here I guess

14:34 are some of the ...

14:35 blarf: rhickey: would it be easy to write a matlab-interface? im mostly using python+scipy and i dont know of a java-lib/package with all those neat numerical capabilities. however matlab have loads of code for image processing while python "only" has a lot

14:35 rhickey: Haskell encourages specific types too

14:35 AWizzArd: What about efficiency? rhickey mentioned in his videos that typical operations on Clojure datastructures are slower (of course, they are doing more work under the hood). Somewhere there will be the break even point from being able to use many cores so easily.

14:35 Lau_of_DK: Good evening gents

14:36 blarf: rhickey: would it be easy to write a matlab-interface? im mostly using python+scipy and i dont know of a java-lib/package with all those neat numerical capabilities. however matlab have loads of code for image processing while python "only" has quite a lot.

14:36 rhickey: blarf: didn't you just ask that a second ago?

14:36 blarf: yes sorry, doduble post

14:37 rhickey: I don't know anything about matlab, being a Mathematica user

14:37 cooldude127: i use matlab

14:37 blarf: for audio processing stuff(you dt hat right?)? mathematica is way to expensive for me

14:37 cooldude127: with emacs :)

14:38 albino: rhickey: Are you planning on making a guarentee at some version release of clojure on language change? I'm just curious

14:38 blarf: is that possible?

14:38 rhickey: albino: yes, your money back if not satisfied :)

14:38 albino: rhickey: sweet!

14:39 rhickey: seriously, there will be releases and branches and all that good stuff for independently managing features vs fixes, which right now come together

14:40 this will entail some release management help for me, people willing to backport fixes etc

14:41 I'm pretty sensitive about things that make me less productive though

14:41 * drewr is happy to help release-manage

14:41 albino: yeah, appoint the ether for that kind of stuff

14:42 Chousuke: better break clojure as much as you can now while it's still feasible ;/

14:43 danlei: is there a way to map a method inside a doto?

14:43 like: (map add [button text-area ..., (map #(add %) ...

14:44 or some other way, so that i don't have to type (add button) (add text-area) (add foo)* over and over

14:46 Lau_of_DK: You can consider writing a macro for setting up repetitive UI work ?

14:47 abrooks: rhickey: I think the release management / backporting will go much more smoothly with Mercurial/git. I suppose I still owe you some sort of summary of what that would look like.

14:47 hiredman: I have a j-add macro that just .add()s the rest to the first

14:47 lisppaste8: url

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

14:48 Chouser: abrooks: it wouldn't be very hard to let rich manage HEAD in svn, and have a "master" git repo with all the release versions to support backports etc.

14:48 lisppaste8: hiredman pasted "j-add" at http://paste.lisp.org/display/70729

14:48 albino: abrooks: svn can still do tags and branches :)

14:48 abrooks: Chouser: I've considered that but that only works when there's one branch or if there's an official committer for each svn branch.

14:49 drewr: albino: Yeah, it can *create* branches. Pretty much useless after that. :-)

14:49 abrooks: albino: Uh... No. It PRETENDS to do tags and branches. Don't get me started on Subversion... ;-)

14:49 Chouser: abrooks: yes, rich would be the official commiter for the only svn branch.

14:49 abrooks: drewr: Right.

14:49 albino: are you guys just speaking in respect to merges?

14:50 danlei: hiredman: thanks

14:50 hiredman: I think this is the first macro I wrote

14:50 abrooks: Oh, sure, one can create a preponderance of branches in Subversion. Good luck merging them back together again in any real-world sort of manner.

14:51 albino: Merging is so weak in Subversion as to be mostly useless. Cherry-picking and rebasing are entirely missing.

14:51 rzezeski: You can merge them back, it's just harder to do so if you create massive changes and don't keep the branch in sync with the head

14:51 Chousuke: might prefer mercurial over git for clojure though. For better windows support.

14:51 I'm fine with it as long as it's not SVN or CVS ;(

14:51 Chouser: abrooks: the benefit of my recommendation is that rich could continue to ignore the VCS discussions that he finds unproductive, and the people actually doing the merges could use a sufficiently powerful tool (like git)

14:52 rzezeski: CVS is definitely a nightmare, the fact that SVN doesn't treat branches or tags specially I think is a good step away from CVS

14:52 danlei: besides the macro, there is no way of just kinda mapping them, right?

14:52 abrooks: Chouser: I know. I had considerations along those lines. git-svn goes a long way.

14:52 Chousuke: danlei: mapping what? .adds?

14:52 danlei: mapping a method inside a doto, yes

14:52 hiredman: danlei: I think I did something like it with reduce

14:53 Chouser: danlei: (doseq [i [(Button.) (Label.) ...]] (.add parent i))

14:53 ...or some such.

14:53 danlei: Chouser: mh, ok. thank you

14:53 Chousuke: does that work inside a doto?

14:53 Chouser: no

14:54 danlei: its just calling .add on parent, so no doto required

14:54 hiredman: like (reduce #(do (.add %1 %2) %1) (concat [parent] [stuffs to add]))

14:54 Chousuke: danlei: (doto thingy (.something) ((fn [obj] (doall (map (.add obj %) things-to-add)))) ?

14:54 oops.

14:54 missing a #

14:55 I hope I counted the parens right, too :p

14:55 danlei: hm

14:55 Chousuke: that should work with the new-style doto I think

14:57 danlei: ok, thanks all. i guess i'll just stick with something like hiredmans macro

15:00 AWizzArd: What about efficiency? rhickey mentioned in his videos that typical operations on Clojure datastructures are slower (of course, they are doing more work under the hood). Somewhere there will be the break even point from being able to use many cores so easily. But how fast will code run on dual cores of today?

15:01 Chouser: AWizzArd: are you comparing to Java or something else?

15:01 hiredman: "faster then Ruby"

15:02 AWizzArd: Chouser: Java or sbcl

15:02 hiredman: than

15:02 danlei: sounds a little like "it's still fast enough for our neurons" ;)

15:03 Chouser: AWizzArd: Anytime you *must* have Java speed, you can write it in Java and still integrate cleanly with Clojure. So from the decision of an up-front decision, you've got coverage.

15:03 blarf: can i filter in nly one sec?

15:03 Chouser: AWizzArd: in practice, I suspect that will hardly ever happen (depending on your problem space)

15:03 Chousuke: blarf: you might want to rephrase that question.

15:04 filter in only one second? sequence?

15:04 Chouser: AWizzArd: most modern apps aren't bound so much by slow data structres as poor algorithm choices. Clojure will help you choose good algorithms or swap in better ones as needed.

15:04 AWizzArd: Chouser: for this commercial project this will probably not be a problem. I am thinking about my Genetic Programming lib. It runs fast in sbcl and is trivially and pretty much perfectly parallelizable, even with mutable state.

15:05 Chouser: AWizzArd: in some cases where you've got the "best" algorithm, but your implementation is still slow, using Java primitive types and/or Java (mutable) collections from within Clojure code will probably suffice.

15:06 oh, and type hints should go in that list as well.

15:08 AWizzArd: this is difficult to do in GP.. well, I will see how it performs

15:08 When putting code into eval, will it be interpreted or compiled first and then run?

15:08 danlei: is there some kind of tutorial/overview about delivering? i have absolutely no experience with java. let's say i've just a small gui app, only one file. how would i get something double-clickable out of it?

15:09 Chouser: AWizzArd: there is no Clojure interpreter

15:10 AWizzArd: then I will probably have to write my own eval

15:10 danlei: sorry, if the question sounds rather stupid. a pointer to something i should read would be enough

15:10 Chouser: why?

15:10 hiredman: danlei: you need to learn about jar files

15:10 AWizzArd: because compilation is not an option for most things in GP

15:11 it will slow down the fitness function by some orders of magnitude

15:11 Chouser: danlei: there's a thread on the google group

15:11 hiredman: oh, yeah

15:12 danlei: hm, ok. i'll search that thread and read some tutorial about .jar files, then i'll ask again, if there are problems. thanks

15:12 hiredman: someone (not me) made this: http://rpdillon.googlepages.com/creatingexecutablejarswithclojure

15:12 danlei: hiredman: thank you

15:13 Chouser: AWizzArd: the fitness function is run very few times, I guess?

15:15 AWizzArd: Chouser: nope, very often

15:15 only for complex problems it makes sense to compile the code

15:16 Chouser: AWizzArd: but compilation is probabl an O(n) one-time hit, and then you get all the benefits of JIT to make it run fast. Are you sure it won't be slower to interpret it each time it's run?

15:17 AWizzArd: My system gets a problem description and some tools for manipulating the domain. It then will write computers programs alone, without human interaction and see how good they perform. Then the programs rewrite themselves to solve their problem better and better.

15:17 I am very sure that for many problems it is very much faster to not compile the generated programs first before measuring their fitness.

15:19 cemerick: AWizzArd: I've done some GP stuff in clojure. the compiler is your friend :-)

15:20 AWizzArd: I will have to see how it will perform, compared against my system that runs on sbcl

15:20 cemerick: I suppose if you have a very simple problem domain, strictly evaluating the programs *might* break even.

15:20 AWizzArd: I suppose Clojure will be a bit slower

15:20 cemerick: doesn't sbcl compile everything as well?

15:20 danlei: cemerick: by default: yes

15:20 AWizzArd: cemerick: when you enter something in the repl yes

15:21 cemerick: oh, in sbcl you explicitly eval forms to force interpretation?

15:21 AWizzArd: but eval has not a direct call to (compile ..)

15:21 cemerick: of course

15:21 if I would use compile instead the runtime will be 60x worse

15:22 cemerick: I've no experience to back this up, but I'd suspect that indicates a slow compiler in sbcl, not any virtue of interpretation.

15:22 (experience w/ sbcl, that is)

15:22 AWizzArd: no, in GP one uses an interpreter in pretty much every language

15:22 only for a few problems a compiler is used

15:23 if you want to do GP in a non-Lisp you do this by (in some sense) writing your own little lisp interpreter

15:23 cemerick: in the domains I've used GP in, the runtime of the programs themselves outstrips *any* compilation time by a wide margin. I guess it comes down to one's domain.

15:24 AWizzArd: how do you think can one write a Python program for example, which writes Python programs, runs them, and let's them rewrite themself?

15:24 cemerick: did you use GP or GA?

15:24 cemerick: GP

15:24 AWizzArd: in Lisp?

15:24 cemerick: Mostly, yeah.

15:24 Pupeno: Any recommendation on how to debug SQL statements when using contrib?

15:24 contrib-sql I mean.

15:25 AWizzArd: cemerick: so you were doing (compile ...) in your fitness function?

15:26 cemerick: Absolutely. Like I said, the runtime of the programs being generated was significant, so compilation time was an easy choice.

15:26 AWizzArd: well, then you must have had very specific requirements

15:27 this is really not common at all in GP

15:28 for example, if you want to generate chess playing programs, then it would make sense to compile them first

15:28 cemerick: It's always been a hobby for me, so I suppose I don't know what the norms are among "serious" practitioners.

15:28 AWizzArd: as each of them will probably run for many minutes or even hours

15:28 but then again you would need hardware for several trillion dollars to get acceptable results

15:29 cemerick: yeah, all of the GP I've ever worked on produced programs that ran for many minutes, and often hours.

15:29 AWizzArd: right, then compile makes sense

15:29 cemerick: lol -- or, just a lot of patience :-)

15:29 like I said, it's a hobby

15:29 AWizzArd: I see

15:30 cemerick: AWizzArd: what is the typical runtime in your domain per individual?

15:30 blarf: ok so anyone think they can beat an optimal tic-tac-toe-player? (well byd efinition it is impossible but anyway)

15:31 Chousuke: blarf: do I get to start? :p

15:32 AWizzArd: cemerick: it depends very much on the problem domain. If you want to solve a difficult problem then it means your search space is huge. Only problems for which generated programs can run within fractions of a second can be solved with todays hardware.

15:32 If you have programs that run for minutes then GP won't find a good solution. Or better said: it will find solutions only for very trivial problems.

15:32 Or it would find great solutions after some hundred million years of runtime.

15:33 Chouser: compilation should take linear time based the "size" of the code being compiled, on the order of 1 or 2 milliseconds

15:34 if each function is going to run any longer than that (either individually or over several trials) when interpreted, the compiled version should win.

15:35 AWizzArd: Chouser: in a few days I can do some comparisons for you and tell you the facts.

15:35 Chouser: AWizzArd: ok, great.

15:36 blarf: well: warning, the program is quite ugly in its present form, bloated and a functions i can probably refactor away

15:37 AWizzArd: Chouser: and keep in mind that programs a GP system generates are usually most extremly different from what humans would write. The compiler will have to do much more work.

15:37 blarf: http://en.wikipedia.org/wiki/Tictactoe, actually step 4 in stragey might not be fully implemented, im just doing option 2(maybe thats even bad) but anyway it plays really well.

15:37 AWizzArd: if your problem is in a binary domain there will be thousands of (or true true)'s in your code, or something similar

15:37 huge chunks of ands ors and nots that do nothing at all

15:38 the compiled code often won't run faster, and it adds compilation overhead

15:39 lisppaste8: blarf pasted "tictactoe" at http://paste.lisp.org/display/70735

15:40 AWizzArd: So the Clojure (eval ...) will call the compiler, is that correct?

15:42 Chouser: AWizzArd: yes

15:42 blarf: funny i was starting on some simple GP

15:42 Chousuke ^^

15:44 rhickey: step debugging very sweet in JSwat, moves between files etc just fine on compiled .cljs

15:44 hiredman: where can I get a pre-AOT clojure.contrib?

15:44 AWizzArd: Chouser: I will write my own interpreter then, it will be just 30-50 LOC

15:44 rhickey: wish it could generically display collections :(

15:44 AWizzArd: it is typical anyway for GP to not use Lisps eval but write ones own fast-eval instead

15:44 Wodin: rhickey: Hi. I'm having a problem with current versions of Clojure that goes away when I revert r1047 and 1048. See http://paste.lisp.org/display/70670 for details. Is it a bug?

15:45 AWizzArd: one, that is not doing as much work as eval, by just working on a few cases in the cond

15:45 hiredman: (. dcm getString tag) does not look right

15:46 Wodin: hiredman: Why not? :) It worked in the September release of Clojure (and several releases since then) but stopped again at r1047.

15:46 rhickey: Wodin: I saw, will look into it, it's a problem in that the compiled code has things flagged as bridge which shouldn't be, but if I allow bridge methods then other users complain because the compiler starts using bridges in the wrong contexts

15:47 hiredman: Wodin: maybe I am wrong

15:47 Wodin: rhickey: OK thanks. Not urgent. Just wondering :)

15:47 Chouser: hiredman: that's just a less-frequenly used format for (.getString dcm tag)

15:47 hiredman: ok

15:47 rhickey: Wodin: I haven't found a recipe that works for all cases that have come up

15:48 Wodin: rhickey: *nod*

15:48 rhickey: i.e the change at 1047 was because someone else broke when bridges were allowed

15:48 Wodin: rhickey: I see

15:49 Chouser: rhickey: I assume you can't start with non-bridge and failing to find any fall back to bridged methods?

15:49 * Wodin pretends to know what bridges are

15:49 rhickey: basically javac is producing junk as far as these modifiers go

15:49 Wodin: heh

15:49 rhickey: so it messes up reflection, when you are trying to tell which methods are 'real' methods and which were generated by the compiler for generics

15:51 methods present in the declaration of the concrete class shouldn't be flagged as volatile/bridge but are in some cases, I think when base is abstract+generic

15:52 I asked about it here and got a collective shrug: http://groups.google.com/group/jvm-languages/browse_frm/thread/a64c755db0a91c1c#

15:52 Wodin: rhickey: So is it a bug in javac then? Is there a way to fix it when compiling the java code that I'm trying to call?

15:53 rhickey: Wodin: I doubt you have control over that

15:56 Wodin: Based on that thread it looks like the JVM's reflection is broken. I suppose normal Java programs just don't need this level of control or something?

15:59 rhickey: I guess the javac guys have code that disentangles this, but it's not exposed for the rest of us

16:00 Wodin: Well, if that's the case, then at least there must be an answer :)

16:01 rhickey: As some people in the thread mentioned, you can figure it out from looking at the bytecode of the class, but Clojure doesn't do that, nor would I want to. Reflection should work for this simplest of jobs - telling you the declared methods.

16:03 Wodin: Sounds reasonable.

16:03 Did you ever ask on the javac compiler-dev list?

16:03 rhickey: no, I didn't have time for that

16:04 Wodin: OK

16:04 rhickey: I have my own bugs to worry about :)

16:04 Wodin: :)

16:04 rhickey: plus I have to deal with what's out there

16:04 If they fix it in 7 that doesn't help me

16:06 cemerick: rhickey: I was going to say, there's *lots* of 1.6 compilers out there, churning out classfiles :-(

16:06 Wodin: Yes, but I suppose there's a small chance that they do it without looking at byte code or something. I know far too little about all of this, though, so that's quite possibly a stupid thought.

16:06 rhickey: right, and I'm not arguing against someone following up with Sun

16:07 I figured the jruby/jython guys would know, given their proximity

16:19 cemerick: do jruby/jython produce bytecode these days?

16:23 walters: cemerick: i think both have hybrid models

16:23 cemerick: i.e. some AST interpretation and some bytecode

16:28 albino: cemerick: the jython guys are working on an AOT compiler

16:35 Chouser: does Clojure run on JVM 1.4?

16:36 hiredman: I do not believe so

16:36 Wodin: Chouser: I've only ever seen mention of 1.5 and 1.6.

16:36 Chouser: ok, thanks.

16:36 hiredman: it would be cool

16:37 kib2: hi

16:39 Lau_of_DK: yo

16:54 cemerick: Chouser: it did run well on 1.4 some months ago. I haven't checked it since then.

16:56 hiredman: !

16:56 cemerick: special build?

16:57 wait

16:57 I may have been trying 1.2

16:57 cemerick: No, right out of svn.

16:57 This was a while ago, though. Maybe April-ish?

17:18 MarkVolkmann: What does this syntax mean? #'name

17:18 wwmorgan: (var name)

17:19 Chouser: normally 'name' evaluates to the current value stored in the var named 'name'. #'name or (var name) evaluates to the Var object itself.

18:42 are we not naming files with _ 'foo.bar.bing_bang.clj' for namespaces with - 'foo.bar.bing-bang'?

18:47 user=> (compile 'clojure.contrib.seq-utils)

18:47 java.lang.Exception: Namespace name must match file, had: clojure.contrib.seq-utils and clojure/contrib/seq_utils.clj (NO_SOURCE_FILE:0)

19:11 ah, looks like that was introduced with new :genclass at rev 1110

19:11 I assume it's unintended?

19:53 MarkVolkmann: What's the shortest way to write an anonymous function that takes one argument and returns it?

19:53 Chouser: identity

19:53 MarkVolkmann: This works. (fn [x] x)

19:53 Can I do something more like this? #(%1) This doesn't work.

19:53 Chouser: #(do %)

19:54 MarkVolkmann: % is short for %1?

19:54 Or is it short for the whole list of arguments?

19:54 Chouser: #(%1) takes one argument and tries to invoke it and return the result

19:54 % is short for %1

19:56 _Jordan_: Hi folks, can anyone tell me why I'm retarded and don't understand the difference between lists and vectors? Here's a stripped-down version of a function I'm writing that's confusing me greatly: http://gist.github.com/26862

20:01 Chouser: _Jordan_: for what it's worth, you've confused me now too.

20:02 _Jordan_: Chouser: ruh-roh!

20:02 duck1123: same here

20:05 Chouser: sort is doing something naughty

20:05 (let [x [3 2 1]] (sort x) x) -> [1 2 3] !!!

20:06 _Jordan_: odd, that's rather... side-effecty, right?

20:06 Chouser: yeah, that's really not supposed to happen.

20:06 Chousuke: ooh

20:06 mmcgrana: o noes

20:06 Chouser: But I think I see it.

20:06 * duck1123 smells another commit comming soon

20:07 Chouser: sort uses java's Arrays.sort, which mutates, and it looks like for a vector the vector's internal array is the one used.

20:08 duck1123: perhaps the value needs to be cloned then

20:09 sort is already a killer of laziness

20:11 _Jordan_: hmm, so what would an idiomatic way to sort a vector be? Admittedly I just saw the sort function and used it :\

20:11 Chouser: _Jordan_: no, you're using it correctly. you found a bug.

20:11 Chousuke: a rather nasty one too :P

20:12 duck1123: gumdrop for _Jordan_

20:12 _Jordan_: lol

20:12 Chouser: toArray() on almost all collections creates a new array

20:12 but on LazilyPersistentVector, toArray() returns the internal array.

20:15 rhickey: are you fixing this as we speak, or should I write it up?

20:24 _Jordan_: Here you go: http://groups.google.com/group/clojure/browse_thread/thread/41521728ed6fb946

20:26 _Jordan_: Chouser: thanks!

20:58 cooldude127: that is some fantastic turnaround

20:58 nice to see how quickly bugs in clojure get fixed

20:58 * rhickey hates bugs

20:59 cooldude127: that's a good opinion for a language designer ;)

21:00 arohner: I asked this question last night, but now that rhickey's around... :-)

21:00 what is the best way to call a java static function using map?

21:01 the best way I've found is (map #(Integer/parseInt %) my_seq)

21:01 and that doesn't look optimal

21:01 rhickey: arohner: why not?

21:01 cooldude127: cuz it feels like it should just be (map Integer/parseInt my_seq)

21:02 arohner: because if I had a clojure function that took one argument, I would call it like (map foo my_seq)

21:02 and (map Integer/parseInt my_seq) does not work

21:02 cooldude127: aka static methods should be just like functions

21:02 rhickey: well, Java methods are not first-class functions

21:02 cooldude127: AHHHHH

21:02 but i really really want them to be!

21:02 ;)

21:04 rhickey: not that there couldn't be sugar for that

21:04 cooldude127: yeah let's have sugar for that!

21:04 jtoy: j/j #vermonster

21:47 mmcgrana: Is there any way to get the absolute path of a file from within the code in that file? *file* seems to give me a relative path.

21:50 lisppaste8: hiredman annotated #70729 with "j-add function" at http://paste.lisp.org/display/70729#1

22:27 _Jordan_: If I have a function that's "returning multiple values" (e.g. returning a vector designed to be destructured), is there a naming convention or something for that? e.g. (defn +foo ...) ?

22:29 Chouser: _Jordan_: nope, not that I know of.

22:30 _Jordan_: Chouser: alrighty, thanks. (Side question: should I avoid such functions?)

22:35 danlarkin: _Jordan_: instead of a vector designed to be destructured could you return a hash-map instead?

22:36 Chouser: _Jordan_: no, I think a vector is fine.

22:36 _Jordan_: danlarkin: Sure. I just thought the destructuring thing was kinda neat :)

22:37 Chouser: you can destructure a hash-map too, which might make sense if you think you might want to return more things later

22:40 drewc: i think i'd rather see a hash map for >2 values.

22:42 and i'd rather see true multiple return values ala CL:VALUES for <2 ... but we can't win them all.

22:42 :)

22:43 Chouser: drewc: you saw the thread with macros for using thread-locals to simulate multiple return values?

22:44 drewc: Chouser: i didn't! got a url or a search term that will point to it?

22:44 Chouser: nm, i think i found it.

22:45 Chouser: drewc: did you? I can dig it up if not.

22:45 we need abrooks' overexpojure

22:47 drewc: Chouser: i've found a thread that has a link to a lisppaste with a VALUES implementation.. if there is another/more i'm all eyes.

22:48 Chouser: not sure, but I think this is all I saw: http://paste.lisp.org/display/68919

22:49 drewc: yup, that's the one i found :)

22:49 thanks for the pointer.

22:53 hiredman: how do I terminate a sequence made with lazy-cons?

22:54 hmmm

22:54 Chouser: you're building the seq with lazy-cons?

22:54 hiredman: nm

22:55 I was returning an infinite seq of nil, instead of nil

23:00 Chouser: so anyone else noticed that you can't compile namespaces with a '-' in their name since 1110

23:02 mmcgrana: is it because of "-" vs"_" in the folder/file names?

23:02 Chouser: appears to be, yes.

23:02 mmcgrana: seems like i'm able to do it, but I've been using _

23:03 actually i'm comfused too about what should be used - i thought at some point we had to use _ because of something internal to java, but maybe that was changed but is now broken?

23:04 Chouser: pre 1110 I'm pretty sure we were supposed to use - for namespaces and _ in file names

23:05 mmcgrana: yeah that's I've been using through 1107

23:06 Chouser: there are still namespaces in clojure.contrib with - in the ns and _ in the filename.

23:06 ...that can't be compiled now

23:07 mmcgrana: o hm which ones?

23:10 Chouser: (compile 'clojure.contrib.str-utils)

23:15 mmcgrana: i haven't been using compilation like this personally, but when i load up the repl with core and contrib in the classpath and use the above compile command, it seems to work, i can use str-join etc.

23:17 Chouser: yes, they work fine still without AOT

23:19 mmcgrana: is it that you can't then use the compiled files? sorry if i'm sounding dense just trying to understand this myself and help out.

23:20 Chouser: when I run that compile command above, I get: java.lang.Exception: Namespace name must match file, had: clojure.contrib.str-utils and clojure/contrib/str_utils.clj

23:21 albino: are dashes allowed in java namespaces?

23:21 _Jordan_: don't think so

23:22 albino: I've never seen it before if they are

23:22 Chouser: no, it would parse as minus in Java source

23:22 albino: oh, right

23:25 Chouser: I assume the desired solution is for dashes in namespaces to be mapped to underscores in class names.

23:26 mmcgrana: makes sense

23:33 o ok i get the error now after upgrading to head - could it have cropped up between 1107 and 1115?

23:33 Chouser: sorry about the confusion - i took post 1100 to literally

23:35 ok im doing binary search now...

23:39 Chouser: 1110

23:39 not 1100

23:39 mmcgrana: a right

23:40 Chouser: line 4501 of Compiler.java

23:45 I should probably just give up on it. I imagine rhickey will be able to fix it in 5 minutes sometime tomorrow morning.

23:46 _Jordan_: Hmm, is there a way to get a list/vector to destructure in the context of a function argument? e.g. so (min [3 2 5]) returns 2?

23:46 mmcgrana: like (apply min [3 2 5]) ?

23:47 _Jordan_: why yes :P thanks

23:47 (sorry, lisp noob)

23:47 mmcgrana: np

23:47 me too

23:52 Chouser: ah, got it

23:54 mmcgrana: what's the deal?

23:55 Chouser: not sure I've got it 100%, but it's a step in the right direction to have line 4501 read:

23:56 if(!nssym.toString().replace('-','_').equals(classname))

23:57 ns: foo.bar-baz path: foo/bar_baz.clj classname: foo.bar_baz

23:57 so the nssym and the classname should not in fact be equal when there's a dash involved.

23:58 ...but I'm not quite sure it's loading right.

23:59 mmcgrana: right. it would make sense to me if clojure namespaces only used dashes and java classes and file paths only used _. if you can use one or the other in a given case then the semantics might get messy

Logging service provided by n01se.net