#clojure log - Apr 21 2009

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

0:21 eee: anyone know how to scramble a vector in clojure?

0:22 that is

0:22 return a new vector

0:22 where all the cells are mixed up

0:22 from orig

0:24 oh shuffle

0:24 would be better to search on

0:25 found discussion

0:33 silly question but I can't figure out how to get the length/size of a vector in clj

0:50 Cark: (count [1 2 3])

0:52 cmvkk: i'

0:52 ve always thought that wasn't as clear as 'length'

0:52 Cark: feels like a little soldier will start counting the items one by one

0:53 cmvkk: or...a puppet vampire?

0:53 Cark: a kind and helpfull puppet vampire maybe

0:55 actually i use count most of the time when designing components in c# or delphi

0:58 Puzzler: I can't get gen-class to work. I get the error "java.lang.Exception: Unable to resolve symbol: Compile in this context"

0:59 Nope, that's not the error...

0:59 Wrong copy and paste.

0:59 java.io.IOException: The system cannot find the path specified

0:59 I assume that it has something to do with it not being able to write out the class to the proper directory.

0:59 I've tried explicitly creating subdirectories called "classes" and such, but to no avail.

0:59 Any suggestions?

1:18 eee: hi again

1:18 accidentally lost my mibbit window

1:19 i'm trying to use (count), but it won't count past 10000 on my collection

1:19 is that typical?

1:20 Jedi_Stannis: what happens after 10000?

1:20 eee: i may have found something that works

1:20 i think it was 100000

1:20 just always shows that

1:21 trying again

1:21 Jedi_Stannis: seems to be working for me

1:21 (count (take 10000000 (repeat 1)))

1:21 eee: really forcing it now: (println "shuffling " (count (seq orig)) " ints")

1:21 try to count one more just for fun

1:22 Jedi_Stannis: does seem to b O(n)

1:22 eee: deduping 20,000,000 ints shuffling 100000 ints

1:22 see what it said?

1:22 what are the odds that there are always exacly 100000 after deduping?

1:22 Jedi_Stannis: possible that theirs a bug in deduping?

1:22 eee: now if I do a smaller initial number

1:23 deduping 200,000 ints shuffling 86492 ints

1:23 see?

1:24 i'm just putting stuff in a sorted-set

1:24 and trying to count the items after

1:25 Cark: count just plain works, there's no question about it

1:25 eee: (def orig (loop [ret (sorted-set) i 0] (if (< i 200000) (recur (conj ret (rand-int 100000)) (+ i 1)) ret)))

1:25 hmmmmm

1:25 coincidence that the rand ints go up to 100000

1:25 that's it!

1:25 probability

1:26 duh

1:26 used the ints up

1:26 thanks!

1:26 need a higher max int

1:26 in the rand

1:28 silly question

1:30 Jedi_Stannis: general question: when writing code, and you notice some repeated code that should be factored out, but you don't have a good name for it - its just some repeated logic - how do you come up with a good name for it?

1:34 replaca: Jedi_Stannis: that's always a tough one. I've never come up with too good a way. Sometimes you can use "helper" kinds of names, but that feels like kind of a cop-out

1:37 Puzzler: Has anyone here gotten gen-class to work?

1:38 Jedi_Stannis: replaca: yeah, I use that sometimes, but its sometimes spread out enough that there's not even a good thing to call it a helper to

1:52 replaca: Puzzler: yeah, I got it to work

1:52 the pretty print stuff depends on it

1:52 Puzzler: I keep getting classpath errors. How do you set it up so that it works?

1:53 Where do I put the "classes" directory?

1:53 replaca: you can see what I did @ github.com/tomfaulhaber/cl-format

1:54 what I have is cl-format/ then under that cl-format/classes and cl-format/com/infolace/utilities/PrettyWriter.clj

1:54 for instance

1:55 and my compile creates cl-format/classes/com/infolace/utilities/PrettyWriter*.class

1:55 You can go look at my build.xml and all the files on github

1:55 (That version is out of date, but easier to see what I did)

1:55 Puzzler: hmmm, I tried doing something like that.

1:56 replaca: Maybe just dowload my project, run ant there to be sure it works, and then compare

1:56 Puzzler: So what does your classpath line look like when you invoke the REPL where you call the compile command?

1:56 Or you do everything with ant?

1:56 replaca: I do everything with ant, but you don't really have to

1:56 I just find it easier

1:57 hang on, I'll go look at the file

1:58 I have .:classes:../clojure/clojure.jar

1:59 at least I think that's what ant is making out of the classpath info

2:33 It is sweltering in SF tonight!

2:47 lisppaste8: hiredman pasted "meta charsequence" at http://paste.lisp.org/display/78942

4:21 hiredman annotated #78942 "add hashCode and equals" at http://paste.lisp.org/display/78942#1

5:18 dysinger: "I for one welcome our new Oracle overlords"

6:27 something: is there a way to restart emacs without closing and opening? I updated my clj-server file, I think there's a way to refresh it, but I can't remember.

6:43 hoeck: something: you can just restart slime, reload any given definition, restart a single mode, but i don't know of a global reset switch

6:44 something: ok, thanks.

7:06 djpowell: Puzzler: have you sorted gen-class yet? Add the source and classes folder to your classpath. And bind *compile-path* to your classes folder, then it should work

7:43 AWizzArd: something: I just close the *inferior-lisp* buffer and then do "M-x clojure" again. This way I can keep my repl history.

7:46 jdz: my slime keeps repl history even if i do ,quit

7:46 and even between emacs restart

11:53 unlink: Is there a j2me port of clojure / is such a port expected to be difficult?

11:55 replaca: unlink: I believe that there are some features missing in j2me that make full clojure difficult

11:55 iirc, it's possible to do an interesting thing but would probably require some reorganization in core

11:56 unlink: oh I see

11:56 replaca: (but I am not the authoritative word here)

11:59 rhickey: svn 1354 adds *clojure-version* - feedback welcome

12:03 replaca: rhickey: could you take a look at http://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib

12:03 rhickey: ?

12:03 * danlarkin cheers for *clojure-version*

12:04 danlarkin: a welcome addition

12:04 unlink: Hmm, I was looking for something just like that, though noting the svn revision would be nice when appropriate

12:04 replaca: rhickey: This is the "home page" of the auto generated doc for contrib and it has some boilerplate on who and what contrib is about that I'd like your input on

12:05 rhickey: unlink: svn rev is not in the cards at present

12:05 unlink: ...in the cards?

12:05 danlarkin: unlink: it's been discussed, but deemed impractical IIRC

12:06 unlink: oh

12:06 Technically difficult?

12:06 replaca: unlink: the problem is that an svn rev is hard to do "portably"

12:06 since different floks get at the source differently (e.g., through git mirrors and the like)

12:07 *folks

12:07 unlink: Oh, well you can always say nil if you can't find it, I guess.

12:07 rhickey: replaca: looks like a good start - brief descriptions would be nice, I think you might want to use heading rather than bold on the names, also some subdirs are included, cluttering things up if they're not truly public entry points

12:08 replaca: rhickey: thanks, yeah there is still a lot of formatting work

12:08 to do

12:09 rhickey: the short descriptions are going to be the responsiibility of the various contributors

12:09 rhickey: you can scroll down to pprint and see the idea

12:10 rhickey: replaca: makes sense, also just gen semantic markup - maybe someone will contrib some CSS

12:11 replaca: I'm also going to suppport an exception tag on the namespace to say "don't document" and I think I'll just fold the sub-namespaces in under the primary namespaces for "cleanliness"

12:11 rhickey: I'm also going to add a table of func names with direct links on the overview page for quick perusal

12:12 and an index page

12:12 rhickey: replaca: you should note that projects get added at my discretion - the talk on the group has largely ignored that. contrib is not a free-for-all. But your suggestion to release independently, talk about on group, offer to contrib is still correct.

12:12 replaca: but these docs and nav pages much appreciated - thanks!

12:13 replaca: the problem with google wiki is that it's pretty restricted - I'm figuring I'll generate a second product which is pure semantic HTML in a zip file for consumption by others

12:13 but, one thing at a time :-)

12:14 rhickey: OK, I'll tweak the wording appropriately

12:14 thanks!

12:22 stuhood: rhickey: that 'RC1' status isn't in effect until you roll another release, correct? perhaps versions checked out of SVN shouldn't be labeled that way

12:26 rhickey: stuhood: are you suggesting toggling that for a build that never gets checked in? Normally it will be SNAPSHOT between releases

12:26 but prior to a release?

12:28 stuhood: rhickey: ahh... as long as it would normally be 'snapshot'. i figured the version would change as the last commit before a release

12:39 replaca: rhickey: oh, could you put a link to that overview page in the project description on google code? Do you want me to write up some words and send them to you?

12:41 technomancy: are there any examples of enlive that use snippets?

12:41 the bundled examples are rather... terse.

12:42 replaca: technomancy: I think that dnolen is working on some more examples

12:42 noidi: can you recommend any tutorials for someone coming to clojure from OO?

12:43 or recommend any clojure _application_ code to read

12:44 something that deals with domain-specific entities, and not just basic clojure data structures

12:44 i've spent the last 3 days just thinking about this thing and it's driving me nuts :)

12:45 technomancy: noidi: Mire is a small complete application that might be good: http://github.com/technomancy/mire

12:45 noidi: technomancy, thanks!

12:45 technomancy: noidi: I built it up step-by-step with each step in a separate git branch, so you can follow along with the development

12:45 each step builds on the last and adds a few key concepts

12:47 noidi: a "gitorial", cool :)

12:47 btw, is On Lisp? worth reading?

12:49 Raynes: noidi: Yes.

12:50 replaca: noidi: many of us love it. It does give you some flavor of the power of Lisp

12:50 noidi: I tried to take a look at the final chapters of Practical Common Lisp, which solve "real-world" problems, but they all seem to use CLOS :/

12:51 replaca: noidi: You can almost think of it as the equivalent to OO's patterns for Lisp

12:51 noidi: okay, then it's probably just what I need

12:55 while OO is not the right answer for every problem, it's become my default approach to programming (i.e. maybe 80% of my code is OO)

12:56 and now when learning Clojure, which seems very cool, I'm completely at loss when "everything I know about sw architecture is wrong" and I have no idea of the alternatives :)

12:57 but I'll read On Lisp, maybe it has the answers I need

12:59 replaca: noidi: When what you have is OO tools, you might as well take an OO approach. But it is limiting in some ways.

13:01 noidi: In clojure you can think about taking fragments of the OO system and treating them functionally by doing attributes with maps, alternative functions with multi-methods, and visibility directly with namespaces

13:02 noidi: The advantage here is that you only use what you need and you can take advantage of commonality elsewhere

13:02 hiredman: ~ping

13:02 clojurebot: PONG!

13:02 noidi: replaca, my problem isn't technical, it's philosophical :)

13:03 I know that I can simulate aspects of OO that I need

13:03 but first I have to unlearn using OO "by default", i.e. writing mostly OO code

13:06 because if I write Clojure that looks like Python with a different syntax, I might as well stick with Python

13:06 replaca: noidi: yeah, that's a big thing. I still struggle with that and I learned Lisp before OO!

13:07 but there's been *a lot* of OO in the middle

13:08 noidi: But don't worry too much - let it seep in.

13:08 technomancy: clojurebot: welcome back!

13:08 clojurebot: Pardon?

13:08 noidi: replaca, heh, thanks :)

13:08 replaca: Your first program doesn't have to be a functional masterpiece

13:23 Chousuke: noidi: I think the important thing is to try to stop thinking of programs as a series of actions to execute. instead, it helps to try to visualise your problem as a series of transformations.

13:32 replaca: hiredman: is it possible to make clojurebot ignore the autodoc robot updating the contrib wiki? That might get annoying.

14:14 maacl: How would I add all jars in a given dir to the classpath using add-classpath?

14:14 AWizzArd: write a shell script

14:15 maacl: Yeah, but if I really wanted to do it with add-classpath :-)

14:15 AWizzArd: Oh, oki, inside Clojure

14:16 in each .clj file the variable *file* is bound to the string which contains the path+filename of the respective file

14:16 maacl: yeah

14:16 AWizzArd: via (.getParentFile (java.io.File. *file*)) you have the current directory

14:17 try (vec (.listFiles (.getParentFile (java.io.File. *file*))))

14:17 That should get you started

14:17 maacl: AWizzArd: thanks

14:19 AWizzArd: rhickey: thanks for *clojure-version*

14:20 rhickey: AWizzArd: not sure I'm using it right yet, but you're welcome!

14:21 AWizzArd: I am glad that the infrastructure for it showed up. Good direction

14:22 technomancy: maacl: one trick I'm experimenting with is unpacking jars into a dependencies/ directory, then adding that to the classpath. that way you can add new dependencies without changing the classpath.

14:22 clojurebot: classpath is (System/getProperty "java.class.path")

14:22 technomancy: maacl: since add-classpath is Fraught with Peril.

14:24 Cark: ~add-classpath ?

14:24 clojurebot: classpath is (System/getProperty "java.class.path")

14:25 Cark: if i add tehcnomancy's "Fraught with Peril", will it overwrite this ?

14:26 noidi: is it possible to shadow core names in a namespace?

14:27 durka42: Cark, i don't think so

14:27 kotarak: clojurebot: add-classpath is also Fraught with Peril!

14:27 clojurebot: 'Sea, mhuise.

14:27 noidi: there are a few generic names that I don't need, but which conflict with the ones I'd like to use in my ns

14:27 technomancy: noidi: you need to use refer-clojure to exclude the core names; see enlive for an example. but it means people won't be able to refer to your namespace as a whole

14:27 durka42: ~add-classpath

14:27 clojurebot: add-classpath is bad, avoid it. I mean it!

14:27 durka42: ~classpath

14:27 clojurebot: classpath is (System/getProperty "java.class.path")

14:27 Cark: nice

14:29 noidi: technomancy, thanks!

14:29 lazy1: Is there a way to find all java object methods and attributes? (something like Python's "dir")

14:30 durka42: ,(.getMethods String)

14:30 clojurebot: #<Method[] [Ljava.lang.reflect.Method;@1c4ff2c>

14:30 hiredman: ,(map #(.getName %) (.getMethods String))

14:30 clojurebot: ("hashCode" "compareTo" "compareTo" "indexOf" "indexOf" "indexOf" "indexOf" "equals" "toString" "length" "isEmpty" "charAt" "codePointAt" "codePointBefore" "codePointCount" "offsetByCodePoints" "getChars" "getBytes" "getBytes" "getBytes" "getBytes" "contentEquals" "contentEquals" "equalsIgnoreCase" "compareToIgnoreCase" "regionMatches" "regionMatches" "startsWith" "startsWith" "endsWith" "lastIndexOf" "lastIndexOf" "lastI

14:30 lazy1: Thanks

14:31 noidi: if I override the names, people can't :use my namespace and have to :require it, and call everything like foobar/baz

14:31 but if I don't override them, I have to add prefixes everywhere to avoid clashes, so foobar/baz becomes foobar-baz

14:31 at least with overriding I can drop the prefixes inside the namespace :)

14:32 hiredman: yes

14:32 require is best anyway

14:32 require :as

14:33 AWizzArd: rhickey: *print-dup* is a fine thing and I am happy that it sits there, waiting for me. Great :) Just one request though: could you maybe add print-dup methods for Atoms, Refs, Agents and Futures?

14:34 cads: Is there a way to search and document functions that specifically take a certain type of argument?

14:35 say I'd like to find the functions that work specifically on sets

14:36 hiredman: cads: clojure.set

14:36 rhickey: AWizzArd: nope

14:36 AWizzArd: Is it better to add those in user code?

14:37 rhickey: nope

14:37 AWizzArd: Hmm, is there technical problem for doing so?

14:37 rhickey: yup

14:37 17 questions left

14:37 AWizzArd: global locking issue?

14:38 rhickey: 16

14:38 AWizzArd: ;-)

14:38 rhickey: if you print the same ref 3 times and read them in, what will you get?

14:38 Raynes: Why do people have to think that without object orientation, code is a monolithic mess :\

14:39 kotarak: Raynes: because they don't know better?

14:40 Raynes: This one instance, this guy is smart, and he has experience with functional programming, but still hates it. x_x

14:40 cp2: thats because languages without oo are heathen!

14:40 kotarak: Raynes: Well. You can't argue about taste, I guess.

14:41 AWizzArd: rhickey: okay, I will think about this issue, thanks for the pointer

14:46 cads: hiredman, how do I look in clojure.set?

14:47 kotarak: cads: http://clojure.org/api#toc649

14:47 hiredman: cads: it is a namespace, it is documented on the api page

14:48 you can also look at clojure/set.clj

14:48 (the source)

14:48 noidi: Raynes, people coming from most other languages have only seen well-design OO codebases, but not well-designed functional ones

14:50 okay, i'm generalizing out of one data point, me, here :) but this is one reason why a person might hold on to OO

14:52 Raynes: It's true if you don't factor in the neat things most functional languages provide to encapsulate code, like Clojure's namespaces.

14:52 noidi: and with any paradigm it takes practice to understand which parts of it are dogma, and which parts are beneficial (and why)

14:53 for me it takes real effort to ignore the religious fervor of paul graham's writings about lisp

14:54 drewc: noidi: graham can be safely ignored all-together ;)

14:55 hiredman: ~Paul Graham

14:55 clojurebot: Paul Graham is the creator of the other new lisp

14:55 Cark: drewc : except maybe for reading on-lisp

14:56 noidi: hmm, that sentence came out kind of weird, I had a point but lost my train of thought while writing a follow-up sentence :)

14:57 drewc: Cark: _maybe_ .. i read on lisp years ago, and have never needed it for reference. PAIP or PCL, OTOH, are sitting next to me right now.

14:58 cemerick: "other new lisp"? That's sort of generous, no?

14:58 drewc: Cark: if On Lisp really taught me anything, it's that graham doesn't quite know what he's talking about :)

14:58 noidi: I guess the point was, that OO has been diluted from a religious silver-bullet thing into something that's "just the way it's done"

14:59 so compared to that, claims that OO is rubbish and functional programming is the one true way seem a bit loony and silver-bulletish

14:59 drewc: is this an OO vs Functional conversation?

14:59 because i'm a CLOS programmer ... ehem... and don't see the issue ;)

14:59 noidi: s/conversation/monologue/

14:59 ;)

14:59 AWizzArd: rhickey: I would love to use my remaining 16 questions *g*. What is the problem with printing refs or atoms in a dup way? For example (defmethod clojure.core/print-dup clojure.lang.Ref [o, #^java.io.Writer w] (.write w (str "(ref " @o ")"))) seems to work for a simple case such as (pr-str (ref {:a 10, :b 20, :c (ref {})})). When I (read-str) the result of that I get: (ref {:c (ref {}), :b 20, :a 10})

15:00 drewc: in fact, if one accounts for dynamic slot values ala ContextL, CLOS can be pretty close to 'pure', in the lack of side effects sense.

15:01 but this is the wrong channel for CLOS discussions, so i'll slink back to my hole :)

15:01 noidi: I was just responding to [21:38] < Raynes> Why do people have to think that without object orientation, code is a monolithic mess :\

15:01 Cark: drewc : oh come on, very good book for beginners

15:01 it helped me quite a bit with understanding macros

15:01 noidi: before turning to rambling :)

15:02 rhickey: AWizzArd: you didn't answer my question

15:03 AWizzArd: I would say that if I print a ref several times in a row then they should all yield the same result as long there was no state change during these prints.

15:04 leafw: any setLookAndFeel wizzard could explain me why setting the look and feel in a static { } block of a class has no effect at all? Would appreciate very much.

15:04 drewc: Cark: what it doesn't help with is to know when not to use macros. I've seen enough graham-ified codebases in the real world to have some serious issue with that book and the authors claims and style. this is opinion, YMMV.

15:04 leafw: that class is loaded. Methods are being called from it.

15:05 AWizzArd: One potential problem I see is if there is no global lock: when we have refs of hashmaps in which the values are refs again, then there may be state changes during the printing which the MVCC can not prevent from creating inconsistent data

15:05 rhickey: AWizzArd: print-dup [aref aref aref], then read it in, probably not what you want (3 different refs)

15:07 i.e. if a reference type appears more than once in an object graph, it will become multiple independent refs in the read result. For values this is slightly wasteful of space, but harmless. The only reason it works for vars is becasue they are interned

15:07 because

15:08 AWizzArd: ok, I begin to get your point

15:10 durka42: could they be printed with the hashCode() attached somehow, and then the reader could string them back together

15:11 hiredman: ...

15:11 durka42: ^ that means i said something stupid

15:12 AWizzArd: Well, maybe it is not that stupid

15:13 Raynes: hiredman: You're an arrogant stubborn bastard. But you're still my hero :> <3

15:14 AWizzArd: rhickey needs to care about a solution that works in general. But perhaps for some use cases the simple approach from above may work out, so some users could think about having this in their own code.

15:15 hiredman: if you print-dup things on different jvms and then both on one jvm, there is a potential for collisions

15:15 (using hashcodes)

15:16 durka42: true

15:17 cemerick: hashcodes are absolutely not meant to be "portable". You would definitely have rely upon object equality.

15:17 AWizzArd: Although this does not have to be a problem. Whatever the hashcode may be, it would just have to be unique, so that one can identify the same ref.

15:17 clojurebot: this is not a bug

15:43 hoeck: should select-keys return a map of the same type as the given map?

15:43 I'm just wondering wether the current behaviour is a feature or a bug

15:43 after selecting keys from a lazy-map

15:45 kotarak: hoeck: maybe a bug in lazy-map. Can you describe me how to reproduce?

15:46 hoeck: kotarak: no, select-keys always returns a PersistentArrayMap, it uses the {} literal instead of (empty..)

15:46 kotarak: Ah. Ok.

15:47 hoeck: it took me a while to figure this out, as I was expecting select-keys to return a map of the same type

15:48 kotarak: I would think so too after reading the docstring.

15:48 hoeck: but it doesn't explicitly mention it

15:49 kotarak: Which I would expect, that it is a generic function not limited to hash-maps.

15:49 hoeck: right

16:29 grosours: hi

16:30 hoeck: grosours: hi

17:53 technomancy: so I'm using proxy to wrap a Java class for testing purposes. the class's constructor takes an argument, but for testing this argument is irrelevant. Can I get my proxied object without calling the superclass constructor, or would I need to use gen-interface for that?

19:13 duck1123: has anyone tried updating swank-clojure recently

19:14 I'm getting some errors after the most recent update

19:14 dnolen: what's the error?

19:15 duck1123: Could not locate swank/clj_contrib/pprint__init.class or swank/clj_contrib/pprint.clj

19:16 I'm not sure if it's my version that's messed up, or if it's a result of the most recent merge

19:18 dnolen: yeah swank-clojure added pprint support recently

19:18 do you have the latest version of clojure and clojure-contrib?

19:20 duck1123: yeah, I just pulled them as well

19:24 dnolen: you need to compile clojure-contrib like so:

19:25 ant -Dclojure.jar path/to/clojure.jar

19:25 this will compile pprint

19:25 technomancy: it'd be nice if ant could look for clojure.jar somewhere by default and only need you to specify it if it wasn't found there

19:26 like ../clojure/clojure.jar would be a great default

19:26 dnolen: I agree, it's a bit a annoying to have to specify it.

19:26 technomancy: but I don't know how easy that would be to express in ant's executable xml language

19:27 don't want to get sucked into the turing tar pit

19:27 dnolen: one day clojure package manager and this will all be a bad dream. baby steps...

19:28 duck1123: so do you guys know of anything in clojure-mode that'll allow me to quickly jump to a function's test?

19:28 technomancy: dnolen: =)

19:29 duck1123: how would you calculate that?

19:29 you'd need some sort of convention mapping functions to their tests; none exists for Clojure code that I know of.

19:30 unless you mean using the :test metadatap?

19:30 duck1123: I would adopt whatever convention allowed me to have that

19:35 technomancy: why don't you ask on the mailing list what convention most folks are using?

19:36 we're using a top-level test/ directory with tests all in the same namespaces as they're testing.

19:36 load-foo would be tested in the test-load-foo deftest

19:36 but I don't know if this is common.

19:37 some projects just put tests in src/ and just keep them in different namespaces from what they're testing; contrib does this.

19:46 duck1123: that's pretty much how I have mine. the test for net.mycyclopedia.model.statement/select is in net.mycyclopedia.model.statementTest/test-select in the test/ folder

19:46 Raynes: Ducky!

19:50 dysinger: I suspect that you have to do it like that (duck1123) because you cannot have 2 java classes with the same name in the classpath or one will shadow the other.

19:51 technomancy: dysinger: I realized there actually is a good reason to AOT your tests: you can't use gen-interface without AOT

19:51 dysinger: ah

19:51 technomancy: so if you do need that, then test/ mirroring src/ might not work.

19:52 dysinger: yeah gen-class and gen-interface would both require some AOT

19:53 technomancy: the main use for gen-class is so you can get -main functions to work correctly, right?

19:53 ISTR hearing that using gen-class directly (outside of the ns declaration) was deprecated

20:19 emacsen: I know I'm not the brightest, but does anyone have an example of using lazy-seqs on, say another list, or a file buffer or something where it's not a value you need to calculate?

20:20 hiredman: ah

20:23 dnolen: emacsen: check out duck_streams.clj in clojure-contrib for a file reading example.

20:23 emacsen: k, hold on

20:24 lisppaste8: hiredman pasted "lazy-seq example" at http://paste.lisp.org/display/78988

20:29 emacsen: hiredman, thanks. dnolen yeah I think the duck-streams is just what I needed to see thx

20:39 arohner: cmvkk: my guess as to why it's called length is that it doesn't imply a one dimensional view

20:45 cmvkk: I suppose, although in some sense it does imply a one dimensional view

20:46 oh wait i see what you mean. and I agree.

20:49 arohner: oh right, I should have said count

20:49 what I meant to say is that length sort of implies a one dimensional view, and count does not

20:50 cmvkk: hmm, but in some sense, whatever you're counting is one dimensional anyway.

20:50 like if you have a list of lists, count won't give you a count of every item, just the items in the outer list.

20:52 in that way though, i think count makes sense. in other words, count implies one-dimensionality (which is correct) whereas length doesn't. ...or something.

20:52 anyway, whatever.

22:01 Jedi_Stannis: does anybody have any good pattern for doing before-methods with clojures current multimethods?

22:05 dnolen: Jedi_Stannis: there's not an existing pattern, you could probably accomplish something like it with macros, do you need the full before/after behavior of CLOS?

22:06 if not you could write some simple macros, Rich recently added support for getting specific methods by dispatch type.

22:06 Jedi_Stannis: not really, just basically have some code I want to share between methods really

22:06 a helper function is somewhat un attractive code

22:06 o really? where are the details on that?

22:07 dnolen: not documented yet, get-method does the trick

22:08 takes multifn plus the dispatch value, returns the matching method.

22:08 Jedi_Stannis: hmm, that might be worth looking in to

22:08 joha1: having problems with " (use 'clojure.zip)" in the Repl. I get a "java.lang.IllegalStateException: next already refers to: #'clojure.core/next". what to do?

22:09 dnolen: yeah, it at least allows you share code between specific methods.

22:09 (get-method your-multifn :before)

22:10 arohner: joha1: use "require" rather than "use"

22:10 hiredman: joha1: use require :as

22:10 (require '[clojure.zip :as zip])

22:10 then access via zip/next

22:11 joha1: thanks all, that worked. Have to check the doc for require

22:29 tjkirch: Hi folks. Has anyone had trouble with vimclojure lately? I did some updates and something broke. The keybindings for gorilla just don't do anything now.

22:30 Jedi_Stannis: tjkirch: just ain the process of updating, will let you know how it goes

22:31 tjkirch: Jedi_Stannis: thanks. I'm not sure what happened, but I've been troubleshooting for days.

22:34 I've tried deleting and rebuilding everything, starting with a fresh vim config, manually binding the gorilla functions, but it just beeps. =/

22:36 Jedi_Stannis: now your giving me second thoughts on if I should go ahead with the upgrade...

22:36 durka42: tjkirch: is the filetype clojure?

22:37 tjkirch: durka42: Yes, filetype is clojure, clj_want_gorilla = 1, nailgun is running, etc.

22:38 durka42: hmm

22:39 tjkirch: All of the non-interactive vimclojure features seem to work fine.

22:41 durka42: is vimclojure#NailgunClient right

22:42 tjkirch: I think so - ng is in my path, but I've tried with that set and unset

22:43 Jedi_Stannis: hmm well I can't get vimclojure to build

22:43 java.lang.ClassNotFoundException: clojure.contrib.pprint.PrettyWriter (pprint.clj:23)

22:44 tjkirch: I had that problem as well - it cleared up when I did an "ant clean" before building

22:45 (I cleaned and rebuilt clojure, clojure-contrib, and vimclojure just to be safe)

22:45 Jedi_Stannis: yeah I think it's a problem with my contrib

22:53 hiredman: you need to compile contrib

22:53 pprint doesn't work without gen-class'ing a class

22:53 and you need to compile to do that

22:55 dnolen: from the clojure-contrib directory

22:55 ant -Dclojure.jar ../clojure/clojure.jar

22:55 oops

22:55 ant -Dclojure.jar path/to/clojure.jar

22:55 i mean

23:02 arohner: this is sort of off topic, but there are a lot of smart people on here. I *think* I remember seeing a reference once to Prolog style inferences being NP-hard, and that the same limitation applied to generating optimal SQL plans. Is that true? If so, do you have references?

23:03 hiredman: ~botsnack

23:03 clojurebot: thanks; that was delicious. (nom nom nom)

23:06 replaca: hiredman: how does clojurebot know when there's an svn change?

23:06 hiredman: polls the svn log

23:08 svn helpfully outputs xml if you ask it to, easy on the parsing

23:08 replaca: ahh, ok

23:09 you just do an "svn log" periodically? How often?

23:09 hiredman: five minutes I think

23:10 replaca: Ahh, ok. That's pretty often. I was too shy to think about doing it that often for the autodoc robot

23:10 it seems like autodoc and clojurebot are beginning to chat a little bit now :-)

23:11 hiredman: yeah, well, clojurebot is racing rhickey's announcements

23:11 replaca: :-) and we know rhickey is fast!

23:12 hiredman: google should broadcast svn changes over xmpp somehow

23:13 lazy1: Is there a way to get the numerator and from a clojure.lang.Ratio?

23:13 replaca: hiredman: that would be nice

23:14 hiredman: lazy1: (find-doc "denom")

23:14 or not

23:14 that isn't actually useful

23:14 lazy1: :)

23:15 hiredman: ,(map #(.getName %) (.getMethods clojure.lang.Ratio))

23:15 clojurebot: ("decimalValue" "decimalValue" "hashCode" "compareTo" "equals" "toString" "intValue" "longValue" "floatValue" "doubleValue" "byteValue" "shortValue" "wait" "wait" "wait" "getClass" "notify" "notifyAll")

23:15 lazy1: Did that, what am I missing?

23:16 I can do it ugly with toString and split, but looking for a better way

23:20 replaca: ,(.denominator 1/2)

23:20 clojurebot: 2

23:21 replaca: ,(.numerator 1/2)

23:21 clojurebot: 1

23:21 replaca: lazy1: that what you want? :-)

23:22 lazy1: Yup, where did you find them?

23:22 (and thanks)

23:24 dreish: They're member variables, not methods.

23:24 lazy1: Ah

23:25 s/.getMethods/.getFields/ in hiredman's map

23:25 hiredman: ugh

23:25 exposed fields

23:27 replaca: yup

23:27 we need some more helper funcs for exploring Java classes

23:28 (unless they're already in contrib somewhere)

23:28 hiredman: show is in contrib

23:28 replaca: ahh

23:28 hiredman: uh

23:28 if it is called show

23:28 I forget

23:28 replaca: That's why I'm writing the autodoc tool!

23:29 but I'm not to the index yet :-)

23:29 dreish: Need a function that figures out what function I'm trying to think of.

23:29 hiredman: oh man

23:29 did you see that one on the google group?

23:30 dreish: Not yet.

23:30 hiredman: you give it input and output, and it trys every function it can find looking for a match

23:30 replaca: time to write some AI

23:30 dreish: This was actual code?

23:30 replaca: :-)

23:30 hiredman: dreish: yeah, dunno if it worked I didn't try running it

23:31 this was a month or more back

23:31 dreish: Not sure how I feel about that.

23:31 hiredman: I feel hilarious about it

23:31 dreish: Is every function safe to call with some random input?

23:31 Seems wrong somehow.

23:31 hiredman: uh, depends what functions you have loaded

23:32 arohner: dreish: yeah, you could call unsafeFireTheMissles, as the haskell guys call it

23:32 but if you had a whitelist of fns to call, you'd be fine

23:32 dreish: arohner: Is that in clojure.contrib.missile-utils?

23:33 arohner: I saw a pretty funny blog post of a guy who searched through #haskell for unsafe*

23:36 unsafeFireTheMissle, unsafeIO, unsafeAtAnySpeed

23:36 etc

23:36 http://chrisdone.com/haskell/unsafe.txt

23:38 Jedi_Stannis: hey, I posted the find a function to the google group

23:38 it set *in*, *out* to nil and caught all errors and discarded them

23:38 dreish: unsafeNoReallyWeMeanItThisTimeAndToProveItWeAreGoingToMakeThisFunctionNameUnreasonablyLongToPersuadeYouNotToUseItTooFrequently

23:39 Jedi_Stannis: But did you remember to disable my function that formats the drive containing the given directory, or failing to find it, /?

23:40 Jedi_Stannis: guess not

23:41 I think its safe enough if you know what functions are currently loaded up

23:41 hiredman: Jedi_Stannis: that was cute

23:42 Jedi_Stannis: just got tired of trying to figure out what the function I was thinking of was called

23:42 hiredman: brilliantly functional

23:42 Jedi_Stannis: I have the code if anyones interested

23:44 dreish: How am I supposed to remember what your function is called?

23:44 lazy1: FWIW there's a "show" in clojure-contrib

23:45 Jedi_Stannis: dreish: lol, ill make you an anonymous recursive version of it, so you don't have to remember

23:45 dreish: Jedi_Stannis: Makes sense. I could just remember how it works, and then re-derive it as needed.

23:46 I wrote an anonymous Y combinator in Arc.

23:46 [let f 0 (= f (_ [f _])) f]

23:47 Jedi_Stannis: lol

23:47 im not even gonna try to figure that out

23:47 dreish: Why not? It's lots of fun.

23:47 Jedi_Stannis: I know, I lied, im already trying

23:48 dreish: Arc [_] == Clojure #(%)

23:48 Jedi_Stannis: yeah, I followed arc for lil bit when it came out

23:48 then I found clojure

23:48 dreish: Clojure's a little more useful.

23:48 arohner: a little?

23:48 Jedi_Stannis: yeah, but I think pg likes it that way

23:48 dreish: A smidge.

23:49 Java has some libraries.

23:49 Jedi_Stannis: how's arcs let work? is their same crazy laziness going on in the = form?

23:50 dreish: = is assignment. (let x y @rest) is just (let [x y] @rest)

23:52 f is closed over, so changing the value affects what happens when the [f _] part gets called later.

23:54 Jedi_Stannis: ok, I was thinking it was (let [w x y z])

23:54 which doesn't actually make any sense

23:54 nested [ ] work as _ from the closest scope?

23:54 dreish: Yes.

23:55 Jedi_Stannis: hmm

23:55 #( ) not nesting always bothers me

Logging service provided by n01se.net