#clojure log - May 03 2009

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

0:39 kadaver_: http://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311

0:39 ^^ comment on my mp3player please

1:19 eee: ,(as-str '3)

1:19 clojurebot: java.lang.Exception: Unable to resolve symbol: as-str in this context

1:20 eee: ,(clojure-contrib.java-utils/as-str '3)

1:20 clojurebot: java.lang.ClassNotFoundException: clojure-contrib.java-utils

1:22 replaca: eee: I don't think clojurebot knows about contrib

1:24 eee: oh ok

1:24 i don't know the as-str functionality

1:25 but I was wondering how it is different from str

1:25 and is "as" like the english word 'as' or an abbreviation for something?

1:28 replaca: for things like symbols, it does a "name" call first

1:28 http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/java_utils.clj#68

1:28 is the source

1:28 eee: ok, thanks

1:29 i get it now

1:30 so the return value that you see in the repl

1:30 replaca: p

1:30 eee: isn't really a string

1:30 replaca: *np

1:30 eee: even though you see it

1:30 replaca: for a sym, that's right

1:30 eee: but if you want it in a program as a string you do that

1:31 replaca: the repl will always show you strings in ""

1:31 ,"hello"

1:31 clojurebot: "hello"

1:31 replaca: ,'hello

1:31 clojurebot: hello

1:31 eee: ok

1:31 replaca: but I get tripped up by that all the tiime when I'm not paying attention

1:31 eee: numbers then are a lottle more confusing.

1:32 ,3

1:32 clojurebot: 3

1:32 eee: ,'3

1:32 clojurebot: 3

1:32 eee: what's the difference there?

1:32 3 the sybol and 3 the number, right?

1:33 replaca: ,(class '3)

1:33 clojurebot: java.lang.Integer

1:33 replaca: nope, both numbers

1:33 ' doesn't make it a symbol, just quotes it

1:34 ,'"hello"

1:34 clojurebot: "hello"

1:34 eee: i thought without the quote it was a symbol

1:34 either way

1:34 replaca: ,(class 3)

1:34 clojurebot: java.lang.Integer

1:34 eee: one just doesn't try to expand

1:34 replaca: ,(+ 3 3)

1:34 clojurebot: 6

1:34 replaca: wouldn't work to well with symbols

1:34 *too

1:34 eee: ,(+ '3 '3)

1:34 clojurebot: 6

1:35 eee: ok

1:35 is there an "is symbol" pred?

1:35 replaca: ,(symbol? 'hello)

1:35 clojurebot: true

1:36 eee: duh

1:36 replaca: you could've guessed that!

1:36 eee: too easy

1:36 replaca: :-)

1:36 nice thing about clojure, not too cryptic

1:36 eee: uhhh

1:36 if iyou are used to it

1:36 lots of conventions

1:36 like

1:37 "with-

1:37 i have no idea what all that with stuff is

1:37 replaca: yeah, best to spend time rereading doc on clojure.org and absorbing ideas

1:37 (and then reasorbing them)

1:37 and also reading everyone's code

1:37 eee: someone had a really really long article

1:37 i can't remember where

1:38 replaca: uh, yeah?

1:39 eee: looking now

1:39 http://jnb.ociweb.com/jnb/jnbMar2009.html

1:39 kotarak: mark volkmann prbably

1:39 right

1:40 eee: yup

1:40 i been too lazy to read it

1:40 will check it out now

1:41 replaca: eee: I can't remember, are you a Java guy?

1:41 eee: i doubt it will cover the "with" convention

1:42 well I can cay I know more java than lisp

1:42 replaca: probably not. Some things are just learned by reading lots of code

1:42 eee: and I used to be into c++

1:42 kotarak: with convention?

1:42 replaca: that looks like a good intro (on a quick skim) for someone familiar w/Java and similar languages

1:43 eee: "with" convention

1:43 replaca: yeah, you'll see the with convention used lots of times

1:43 eee: using "with" in front of stuff

1:43 replaca: it's nice once you get used to it

1:43 eee: what's it mean?

1:43 replaca: well, with is usually a block indicator

1:43 ,(doc with-open)

1:43 clojurebot: "([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order."

1:44 kotarak: It usually means that you do something special to the stuff following it, then execute the body and do again something special no matter what happened.

1:44 replaca: it's like a way of capturing a particular try/finally combo

1:44 eee: oh ok

1:44 kotarak: Eg. with-open opens the readers, does the body and then closes the readers in opposite order, no matter whether the body executed normally or threw an exception.

1:45 exactly. Same example. :)

1:45 eee: seems like a lame name for describing that

1:45 i would have never guessed

1:45 replaca: well, when you know the convention, it makes sense

1:45 kotarak: Similar: with-out-str, with-in-str ....

1:45 eee: yeah, I can't guess at those by their names at all

1:45 makes it hard to look at examples

1:46 must be a lisp convention

1:46 replaca: and it makes sense for the convention cause it's always "do the following, with "this" being true for some "this"

1:46 kotarak: eee: you can't accomodate to all users.

1:46 eee: ok

1:46 replaca: not so high-falutin', visual basic and some other have also used it :-)

1:47 though not quite as generally

1:47 eee: ,(doc with-out-str)

1:47 clojurebot: "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."

1:47 eee: i kinda see

1:48 i read that as "str-on-out"

1:48 replaca: that one's nice cause it encapsulates the binding + digging the string out of the string writer which is pretty ugly

1:48 eee: as in apply str to out

1:49 replaca: though I'd use (cl-format nil ...) but I'm weird (& biased)

1:49 eee: so you could implement slurp using with-in-str

1:50 replaca: no, that's not right

1:51 the str in this case is the input

1:51 so instead of reading from *in* it reads from the string

1:51 eee: oh

1:51 ,(doc with-in-str)

1:51 clojurebot: "([s & body]); Evaluates body in a context in which *in* is bound to a fresh StringReader initialized with the string s."

1:51 eee: i see

1:51 replaca: like it says

1:52 eee: i don't like reading docs :)

1:52 a function name can be docs, too

1:52 replaca: It's hard to get good at languages without reading docs and code

1:52 eee: i am one of those annoying people that fight about the wording of interfaces

1:52 replaca: yeah, but that's a trade-off especially at the core

1:53 eee: i am sure it's a convention

1:53 replaca: the more long names you have the more that's clogging up your visual space

1:53 eee: just not necessarily English

1:53 replaca: and the less it simply becomes a semantic primitive

1:54 eee: it works for english by building up

1:54 replaca: good for beginners, but not so good as you get further into it

1:54 eee: but I guess that's what's happening here, too

1:54 kotarak: eee: as I said above: you can't accomodate every user, you might fight a useless fight with someelse because both of you just stick to resp. opinions about wording.... There were all lot of this useless discussions already on the list.

1:54 * kotarak thinks about the ns thread.

1:55 replaca: this is why it's great to have a BDFL

1:55 eee: what happened wit hthe ns thread

1:55 kotarak: Especially when the BDFL is such a smart guy. :)

1:55 replaca: doesn't matter how much we argue, he'll make up his own mind

1:55 kotarak: eee: useless discussion about defns vs. defnamespace vs. ns vs. make-ns ...

1:56 eee: don't know that ai never knew that expression b4

1:56 replaca: yup - I was originally atracted to clojure by the good taste I could see in his decisions when I watched the clojure for lispers video

1:56 eee: that sounds worthwhile to me

1:56 replaca: I haven't been disappointed

1:56 eee: like I think the ns should have departed from java and been slant-separated and then dot sep, vice other way around.

1:57 i just missed a lot

1:57 of the discussions while clj was being solidified

1:57 replaca: eee: open editor, start developing language, then you can make all the rules :-)

1:57 eee: should have been clojure-contrib/java-utils.as_str

1:58 at any rate, i'm happy this is here

1:58 and when I understand it, I'll help explain to others

1:58 but

1:58 replaca: wow, that's one I *really* can't get worked up about

1:58 eee: they will have similar questions

1:58 so good to have good answers

1:59 replaca: yup, Rich almost always hs a really good, thought out answer for what he's doing

1:59 (kind of like Guido, but with a different mindset and therefore different results)

2:00 eee: well, might not be something to get worked up about, but it confused me ... because files are slash sep. could have even been clojure-contrib/java-utils:as-str

2:01 now that's clear!

2:01 or even double colon like c++ :)]

2:01 anyway, my fault

2:01 cause I don't read enough

2:01 i admit

2:02 so lemme try to check out this little book

2:02 replaca: yup, gotta read when you come to a new lang, esp. when it's different than the others you've worked with

2:02 but do it in little chunks and write in between

2:03 eee: i didn't know scala was considered functional

2:04 the real problem is branching

2:04 he had a link to scala and now I'm interested in checking that out for a few minutes :)

2:05 nice chattin. i'm off to read for a bit

2:05 replaca: i know, I keep meaning to check it out too, but it never grabs me (like ruby, haskell and clojure did) when I look at it

2:05 eee: thanks for the info

2:05 replaca: have fun

2:05 np

2:05 eee: i also want to learn J

2:44 kotarak: replaca: is it planned to do two times auto-doc for rev 731?

3:04 replaca: kotarak: whenever you see that it means I'm adding features to the autodoc (or trying to work around stupid google wiki bugs)

3:05 kotarak: replaca: Ok. Just wanted to make sure you are aware of it. Looked a bit ominous: two times the same revision...

3:05 replaca: yup, it often happens

3:05 there will be lots of changes the next couple of days as I add doc

4:28 primus99_: hello

4:34 paddyJ: hello all

5:05 Lau_of_DK: Hi guys

5:05 kotarak: Hi Lau

5:05 Lau_of_DK: Ola mon Kota :)

5:06 p_l: lol. I read that as "Ola has a Cat"

5:12 kotarak: p_l: hehe, kotarak means tomcat

5:12 fyuryu: p_l: are you from PL? ;-)

5:13 kotarak: Or Czech?

5:14 Lau_of_DK: fyuryu: Im from DK :)

5:15 kotarak: Lau_*of_DK*: really? wouldn't have thought of that! ;)

5:15 Lau_of_DK: Hmm :)

5:16 fyuryu: Lau_of_DK: I'm not Danish but I'm in DK right now

5:16 Lau_of_DK: Where are you from ?

5:16 fyuryu: Lau_of_DK: Poland

5:16 Lau_of_DK: Ah ok - Well, welcome to our little tribal community :)

5:17 fyuryu: Lau_of_DK: by "tribal commubuty" you mean Denmark or this channel?

5:18 * fyuryu has been on #clojure for over a year

5:19 Lau_of_DK: I mean Denmark

5:19 * p_l is from poland :)

5:19 Lau_of_DK: Somebody once described Denmark as a tribe and stating that this was the reason for the massive rascism that is present in Denmark - It made alot of sense to me

5:19 fyuryu: Lau_of_DK: heh, thanks. I would't call it tribal, though

5:19 Lau_of_DK: Thats because youre not part of it :)

5:24 leafw: kotarak: question on vimcloure: ant install did it all except creating a vimcloure.jar, for 2.1.0. Is there any build.xml rule for that?

5:24 kotarak: leafw: just ant, without install

5:25 leafw: kotarak: thanks.

5:30 kotarak: java.lang.ExceptionInInitializerError

5:30 hum, which version of clojure-contrib does vimclojure need? I have latest from repos.

5:31 I think it's clojure.jar that is broken actually

5:38 kotarak: leafw: look down the stack trace. There is a line "Caused by..." there is more useful information on what happens.

5:40 leafw: I've rolled back the clojure repos a bit, and now I get : java.lang.ClassNotFoundException: clojure.contrib.pprint.PrettyWriter (pprint.clj:23)

5:41 kotarak: leafw: you must compile clojure-contrib: ant -Dclojure.jar=... in the contrib directory!

5:41 leafw: it's somehow expecting the clojure-contrib.jar to be built with AOT

5:41 aha, so that was it :) trying ...

5:42 kotarak: Tom Faulhabers pretty printer needs AOT...

5:42 leafw: it's cokmpiling now.

5:43 I couldn't understand why the slim.jar had the same size

5:43 now it grew to 1.7 m

5:43 ok worked

5:43 what a detour

5:43 thanks kotarak

5:48 so ant and ant install ... I launched the nailgun sevrer, and now on editing a clojure file, the vimclojure env doesn't seem to have started

5:48 my ,vimrc has not changed since 2.0.0

5:49 kotarak: leafw: what does ":echo b:vimclojure_namespace" say?

5:49 leafw: E121: Undefined variable: b:vimclojure_namespace

5:49 so that is new to me

5:50 kotarak: Yes. It's not started.

5:50 leafw: my nailgun is running

5:50 kotarak: Is the ng client in a different dir now? (maybe before something-2.0.0 and now something-2.1.0)?

5:51 leafw: before, I copied all contents from ~/.vim/plugin/ to ~/.vim/ to make it work. Perhaps my vim setup is not right

5:52 kotarak: plugin? There shouldn't be a single file in ~/.vim/plugin

5:52 The directory layout should as in the source directory.

5:52 leafw: you mean under .vim/ ?

5:52 ant install puts all under ~/.vim/plugin/

5:52 not under ~/.vim/

5:53 kotarak: What did you set the vimdir in local.properties?

5:53 leafw: kotarak: you are right. I did write plugin in there.

5:54 kotarak: Aargh. Another stupid doc phrasing. I should remove the trailing plugin in the README.txt. It is not meant to mean ~/.vim/plugin....

5:54 This might cause confusion.

5:55 * kotarak should hire some professional doc writer....

5:56 leafw: kotarak: it's not easy to write fool-proof docs.

5:57 kotarak: my defense ialsways to write examples. Like, "for *nix systems, use this local.properties file ..."

5:57 Lau_of_DK: Anybody worked out how to fetch the jetty session-id from compojure?

5:57 kotarak: leafw: Yeah. And I'm kind of getting blind for that. There are so many issues with unclear docs, which I just don't notice because I know how it should work...

5:58 leafw: it's all working now. Considering I am not exactly a novice, this was quite "hard" (i.e. non-intuitive, even if the necessary steps where just 3)

5:59 kotarak: leafw: I once put an example with blabla=/path/to/some/where and some guy emailed me an error: "File not found: /path/to/some/where"....

5:59 -.-

5:59 leafw: xD

5:59 kotarak: leafw: did you watch the screencast?

5:59 leafw: "where is the 'any' key?"

5:59 I don't know of any screencast

5:59 kotarak: hehe

5:59 http://kotka.blip.tv

6:00 leafw: thanks

6:00 kotarak: "Press any key" -> Shift, hmmm, Shift, Shift, Shift "Hey! It doesn't work!"

6:00 leafw: xDD

6:00 "Press any non-modifier key" wouldn't work either

6:19 kotarak: Boah. This google groups pages things is sooo idiotic.... Google is hyped too much...

6:23 leafw: kotarak: has the local leaderchanged by the way? '\' doesn't work anymore ... got onlysyntax highlighting

6:24 and :he vimclojure doesn't work

6:24 one feels helpless: the vimclojure-2.1.0 doesn't explain any of this really

6:24 short of reading the doc/clojure.txt

6:54 Lau_of_DK: Does anyone here know, why JSessionID isnt the same all over the site (ie. sometimes it null, nottimes its not) ?

7:37 MikeSeth: why cant you all just use RCS

7:37 err, wrong window

7:39 Chousuke: :)

7:39 Not every one of us is a masochist.

8:12 AWizzArd: Does (count my-list) always return in constant time when my-list is an instance of clojure.lang.PersistentList?

8:24 hiredman: ,(counted? '(1 2 3))

8:24 clojurebot: true

8:25 hiredman: I guess so

8:25 ,(doc counted?)

8:25 clojurebot: "([coll]); Returns true if coll implements count in constant time"

8:25 hiredman: ,(class '(1 2 3))

8:25 clojurebot: clojure.lang.PersistentList

8:26 AWizzArd: So there is probably a private slot in the Java code that keeps track of the number of elements.

8:27 hiredman: ~def c.l.PersistentList

9:21 leafw: anybody on vimclojure : how come 2.0.0 respects the localleader \ mapping but 2.1.0 doesn't react to it?

9:34 :echo maplocalleader claims the var is not defined.

9:41 kotarak: leafw: there was nothing changed with respect to localleader in v2.1.0. If maplocalleader is not defined, it should be mapleader, IIRC. If that is also not defined it should be \.

9:41 You can check the bindings with :nmap without arguments.

9:43 leafw: kotarak: thanks. Something fishy is oging on

9:45 kotarak: so no leaders are defined. Yet, whjen I push \et, the 'e' gets executed to go to end of workd.

9:45 kotarak: It sounds a bit like a messed up installation. The bindings are done by ftplugin/clojure.vim. So you should check that it is sourced and everything works there. Open a .clj file and do a :source ~/.vim/ftplugin/clojure.vim. If it works afterwards, the file wasn't source'd initially.

9:47 leafw: doesn't work either. This is default vim frlo ubuntu with a .vimrc that I have not changed since vimclojure 2.0.0

9:47 kotarak: leafw: what does ":set filetype?" (<- with ?) say in a clojure file?

9:48 leafw: filetype=clojure

9:48 kotarak: Does the nailgun-client variable point to the right place?

9:48 leafw: aha

9:49 not set

9:50 kotarak: So is the client in your PATH then?

9:51 leafw: on min

9:51 one min

9:54 tis is beyond me kotarak

9:54 not enough docs

9:55 "the vimclojure#NailgunClient variable"

9:55 what's that?

9:55 kotarak: Just a sec. Execute the following from within Vim: ":! ng de.kotka.vimclojure.nails.NamespaceOfFile < %"

9:55 clojurebot: vimclojure is state-of-the-art

9:56 leafw: it's not a "let g:NailgunClient=...." by any chance?

9:56 kotarak: What does is say?

9:56 leafw: "let vimclojure#NailgunClient = '/path/to/your/ng'"

9:56 leafw: great

9:56 that would have helped a lot in the docs :)

9:57 kotarak: leafw: this is almost verbatim from the README.txt...

9:57 leafw: indeed: between ----8<---

9:57 kotarak: Yep.

9:58 "Please cut here."

9:58 leafw: my attention span is short. Sorry. I am a dev too; I know how silly our users seem.

9:58 kotarak: Should I use indentation for the examples?

9:58 leafw: what would help IMO is a full vimrc-example file, for instance.

9:59 kotarak: Ok. Just working on a FAQ with example.

9:59 leafw: talking about something generally doesn't help. The user may assume he knows most of it already an ignore it all, and look for the how-to/example.

9:59 and 2.0.0 didn't need this nailgun variable, IIRC

9:59 that confused me.

10:00 kotarak: 2.0.0 also had this.

10:00 leafw: then, I don't understand how I ever got it to work :)

10:00 kotarak: If you didn't need it there, ng should be in your PATH env var.

10:00 What did the ! command above say?

10:00 leafw: I launch my ng from a shell, with a java -cp .... command.

10:00 the ! command said "nothing to see here", not defined

10:01 basically: /bin/bash: -c: line 0: unexpected EOF while looking for matching `"

10:01 kotarak: ? There is something very fishy there...

10:02 When execute the command (w/o : and ! and a file instead of %) in the shell. What does it say?

10:02 leafw: the command translates % to the name of my file

10:02 to: :! ng de.kotka.vimclojure.nails.NamespaceOfFile < test_levelsets.clj

10:03 kotarak: Yes. But the % of course only works in Vim.

10:04 leafw: what is not resolved yet here is the ng variable

10:04 I didn't point it to ng yet. I am trying to figure out how to do so, because I usually launched the nailgun from fiji with a full utomatic classpth setup

10:04 not via ng

10:05 kotarak: Try the following: ":let vimclojure#NailgunClient = '/Users/leafw/Clojure/VimClojure/ng'" and then edit a clojure file. Does it work then?

10:05 This ng is the client. What you mean the server. The server is started outside of Vim with whatever setup you want.

10:05 leafw: tht assumes ng knows how to find the jars I need

10:05 that's what I am trying t ofigue out now

10:06 kotarak: The client just contacts the server and plays proxy.

10:06 leafw: ah!

10:06 great

10:06 see, my assumptions get in th eway

10:07 ok now ng is working, because it already complains about my misue of clojure namespaces :)

10:07 thanks for all the help kotarak. I appreciate your patience very uhc.

10:07 kotarak: Ok. Np. :)

10:07 I'll try to get the docs clarified.

10:08 leafw: also, it' a bit weird that thr nailgun server expects the clj files on the classpath: it should add them as one edits them.

10:08 i.e now I have to add my working dir to the classpath

10:08 and when failing, one doesn't even get syntax highlighting

10:12 kotarak: VimClojure heavily depends on Clojure's introspection. This only works when the namespace is correctly loaded. If you don't have your working dir in your classpath, this cannot happen and the interactive features are then useless. If you edit a lot like this, set "let clj_want_gorilla = 0". Then you get highlighting and <C-n> completion, but doc lookup etc. are disabled. As I said this makes sense, since VC cannot retrieve the necessary info anyway.

10:21 leafw: kotarak: adding to a classpath can be done on the fly, AFAIK. I would have thought that the nailgun could receive file path info from vim and load the parent folder(s) to the classpath

10:21 but never mind, I am sure you went through enouhg :)

10:22 instead, I will add a bash script to my nailgun init file

10:22 to searh for all folders with clojure files in them

10:22 and add the parents as defined in the headers of such files.

10:23 kotarak: leafw: http://kotka.de/projects/clojure/vimclojure.html Scroll down to FAQ. What that have helped?

10:24 leafw: nice. Another box in between showing how to launch the nailgun server (i.e. instantiate java JVM etc) would alos help.

10:24 that is the easy part for me, but harder for non-java devs.

10:27 kotarak: leafw: Like that?

10:27 leafw: kotarak: you are minimalist!

10:27 kotarak: I am?

10:28 leafw: I would say: suppose your jar files are in a folder jars/, and you edit files in a foldeer named src/ .... then, here is how ...

10:28 nevermind

10:28 I guess it's reasonable to assume that someone wanting to use clojure should know something about java classpath.

10:28 and use -classpath instead of -cp, so it makes sense to a first-time reader.

10:29 kotarak: Well. I can't teach them how to turn on their computer. Some minimal set of knowledge might be expected... It's just the question how minimal that set is.

10:29 leafw: up to know, I found it quite high. This FAQ should help.

10:32 kotarak: That's where the impressions differ. Heck, I even did a screencast with the whole install session.... :|

10:33 leafw: kotarak: the missing part of the screensession is: did it help anyone? It's very hard to make good video screencasts. Usually they are too short or too fast. Yours is too fast, IMO.

10:33 s/short/slow/

10:37 lepassive: Hi is enclojure fixed for Netbeans 6.7 yet?

10:38 kotarak: Well. One can always sent me an email: "Hey. Your screencast was too fast/too slow/cool/didn't cover the topic ...." Does one have to ask everything? Should VimClojure pop up a "please fill in this survey since we want to make your experience even more comfortable" window? I don't like this. I get emails like that! "Look, I didn't understand the README there. Can you explain?" But they are rare. The most didn't even read the docs. Improving them doe

10:39 leafw: kotarak: I feel your pain, support has nothing to do with development. Iam very happy already that vimclojure exists, and that you are willing to provide so much on-the-spot support. I am just sharing my experiences from deploying softwar.e

10:48 Lau_of_DK: kotarak: I have a solution to all your problems :)

10:49 kotarak: Lau_of_DK: let me guess it start with S and is all capitals?

10:49 Lau_of_DK: Thats right :P

10:50 kotarak: hehe Can SLIME complete static class members?

10:50 AWizzArd: no

10:50 Lau_of_DK: Not to my knowledge - But Im confident its a small extension

10:51 AWizzArd: Lau, do you have a slime right now before you?

10:51 kotarak: Lau_of_DK: does SLIME highlight *all* functions and macros differently?

10:51 AWizzArd: can you please type into the repl: 1<Enter> then 2<Enter> then 3<Enter> then *3<Enter> and then *1<Enter>?

10:51 Lau_of_DK: No of course not, its a tool for _men_ :)

10:52 kotarak: hahahaha! :)

10:53 leafw: Ok. Explained the setup and made the examples consistent.

10:54 leafw: kotarak: thanks! By the way, the second box doesn't wrap around.

10:54 kotarak: hmm.. Will dig the CSS. Maybe wrapping is turned of for code. I'll check.

10:56 Lau_of_DK: AWizzArd: *1 = 3

10:56 kotarak: Oeh. How do I tell it to wrap around?

10:56 AWizzArd: Lau_of_DK: but it should be 1

10:56 that is a bug in slime

10:56 Lau_of_DK: 3 is fine

10:57 leafw: http://labnol.blogspot.com/2006/10/html-css-trick-for-displaying-code.html

10:57 AWizzArd: try to do the same inside the inferior lisp buffer :)

10:58 Lau_of_DK: :)

10:58 Does this cause any practical problems for you ?

10:58 AWizzArd: in the inferior buffer it works correctly

10:58 leafw: kotarak: bug in vimclojure. sjift+v to select some lines, 'y' to copy and then 'o' to open new line. Then ESC and 'p' to paste: nothing pastes.

10:59 but "0p does paste: somehow, the last register got overwritten by vimclojure indentation in opening a new line.

11:01 kotarak: Hmmm... I see.

11:01 I'll check. Thanks for the link, btw.

11:01 Lau_of_DK: kotarak: You got around to doing anymore screencasts? Like Mercurials patching system?

11:02 leafw: sure.

11:02 kotarak: No, not yet. I'm working on a magit for hg and Vim, but was slowed down by a Vim bug. Screencasts are so much work and with the little one time gets precious. :)

11:03 Lau_of_DK: Fair enough

11:03 Magit is awesome though

11:23 I forgot - How do I un-intern a symbol in my repl ?

11:25 MikeSeth: (def foo)

11:26 AWizzArd: ,(doc ns-unmap)

11:26 clojurebot: "([ns sym]); Removes the mappings for the symbol from the namespace."

11:26 AWizzArd: Lau, I think you can try ns-unmap

11:29 Lau_of_DK: Thanks

11:31 Poll : Why dont more people use Compojure?

11:31 AWizzArd: how many do you think use it?

11:31 And: out of how many who want/need to write a web app?

11:33 Lau_of_DK: I know, that every time I ask a question regarding Compojure in here, its easier to find/write the answer myself than to wait for a reply - So I was just wondering.. I think its a great framework

11:33 mikh_mmbrn: Hi guys! I ve got a problem with serve-file in compojure. could you help me? I'm making a GAE app, and have no idea what is the root path for serve-file

11:34 Lau_of_DK: AWizzArd: like this guy, he's hopeless

11:34 (doc serve-file)

11:34 -------------------------

11:34 compojure.http/serve-file

11:34 ([path] [root path])

11:34 clojurebot: No entiendo

11:35 Lau_of_DK: Specify a the root-path, which is a folder on your class-path, map that to GET "/static" and use that as a reference

11:35 mikh_mmbrn: thanks! i'll give it a try)

11:35 AWizzArd: Btw Lau, maybe you can help me with a Compojure question. I first need to set up all routes I want, and *then* put them as arguments to run-server, right?

11:40 mikh_mmbrn: probably another stupid question: If I compile everything with ant,then the classpath is in <path id="project.classpath"> </path> ?

11:41 in build.xml

11:41 AWizzArd: Lau_of_DK: The question put a bit different: I can not start my server, then define new routes in the repl and let my already running server know about them. Is that correct?

11:54 leafw: AWizzArd: you can add jars and classes to the classpath on a running JVM

12:02 AWizzArd: leafw: but also routes and servlets to Compojure?

12:22 Lau_of_DK: AWizzArd: You can/should start the server first, only giving the port and a name of your serlvet, then you can evaluate routes directly to the repl and immediately see the results

12:27 AWizzArd: Lau_of_DK: ok, so I need to check that out a bit later.

12:43 benatkin: Anyone know of any JavaScript libraries that support and encourage a functional, rather than OO style?

12:45 gnuvince_: benatkin: jQuery?

12:45 benatkin: gnuvince_: jQuery does, more than other languages, but I'd like support for contexts

12:46 er, most other JavaScript frameworks

13:02 Lau_of_DK: benatkin: I'd say ClojureScript is your best bet

13:04 benatkin: Lau_of_DK: interesting

13:05 Lau_of_DK: Very

13:08 benatkin: Lau_of_DK: it sounds like quite a project, though (as in, might not be ready for a while). I'd like to get a library that adds contexts and multimethods to javascript going.

13:09 Lau_of_DK: ClojureScript in its present state is massive, and I must admit that I dont know the full breadth of it. You'll earn a few stars if you finish it though :)

14:26 rlb: Is it possible to ask if an object is an instance of a particular struct-map? i.e. something like (defstruct foo ...) (foo? x)

14:28 Chouser: unless something like that has been added pretty recently, no.

14:29 if the type of the map (structmap or otherwise) matters, you can store it in the map itself.

14:30 rlb: Right -- just wondering about structures more generally. Thanks.

14:33 Lau_of_DK: {:foo {:bar 5 :cec 10}} - if all I know, is the name :foo, and that I need to set :bar to 10, how do I go about that using something like alter?

14:33 clojurebot: alter is always correct

14:34 Chousuke: Lau_of_DK: assoc-in? :/

14:34 Lau_of_DK: aha! Thanks

14:35 rlb: Is there any substantial difference in memory overhead between list and vector for a very large number of objects each containing just "a few" elements?

14:37 i.e. in many Schemes it might be a wash for 2 elements, but for more, in the absence of shared structure, vector's likely better.

14:37 Of course in many cases, it doesn't matter, but sometimes it does.

14:37 Chousuke: I think the vector implementation reserves some space for quick expansion though.

14:38 Chouser: Chousuke: really? that doesn't seem right to me.

14:38 Chousuke: I might very well be wrong :P

14:41 Chouser: I think a list has a whole PersistentList object per element, while a vector has a bit more data in its root object.

14:41 so my guess (and it's only that) is that lists might win memory-wise for very small collections, and vectors would win for larger.

14:42 rlb: It'd be nice to have a rough idea when trying to design something that'll be dealing with very large amounts of data.

14:42 Chouser: it's pretty rare, though, that the memory footprint is the most important difference between the two. Usually needing to look up by index, insert at the head of the seq, etc. are more important.

14:42 rlb: Chouser: certainly.

14:44 Chouser: if you want to keep it really tight, and you're not going to be making changes, put it in an array, and perhaps wrap it with a LazilyPersistentVector

14:45 rlb: You mean a java array, and what's LazilyPersistentVector?

14:45 Chouser: ,(class [1 2 3])

14:45 clojurebot: clojure.lang.LazilyPersistentVector

14:45 rlb: Ahh.

14:46 Chouser: An LPV provides a vector interface, but internally hold the entire contents as a single Java array.

14:46 as soon as you assoc or dissoc or anything, it'll unpack the array into a regular vector trie and return that.

14:47 Lau_of_DK: Where can I find a list of the possible arguments to alter, like assoc, dissoc, etc ?

14:47 rlb: Chouser: OK, interesting.

14:48 makes sense.

14:51 So from what I've read, I would guess that a structmap is just a map that stores its "fixed" elements in something like a vector rather than via a hash. i.e. it knows that :a is in slot 3, and so there's no hashing. Is that right(ish)?

14:53 Lau_of_DK: ,(assoc-in {:foo {:bar 5 :cec 15}} [:foo :bar] 10)

14:53 clojurebot: {:foo {:bar 10, :cec 15}}

14:54 Lau_of_DK: This works great as you can see, but if I want to pass this to alter, to modify a hash-map with several entries, :foo being just one - how would I go about that?

14:54 Chousuke: nothing weird.

14:55 kotarak: (alter some-ref update-in [:foo :bar] inc)

14:55 Chousuke: ,(let [x (ref {:foo {:bar 10} :bar 5})] (dosync (alter x assoc-in [:foo :bar] 42))) @x) ; or htis

14:55 clojurebot: {:foo {:bar 42}, :bar 5}

14:56 Lau_of_DK: update-in - also a good one, where do you guys get this stuff? Rich got some secret newsletter going around?

14:56 Chousuke: there's the api documentation :P

14:56 kotarak: Lau_of_DK: no. Just listening to #clojure and browsing clojure.org/api from time to time.

14:57 Lau_of_DK: Im glad I have you guys :)

14:57 kotarak: I like this alter/update-in style of providing a function to act on the value. :)

14:59 Chouser: rlb: when you provide a key to get or assoc, it still need to look it up. But it looks it up in a shared map of the keys, rather than keys that are stored in each instance. So it's mainly a memory savings, not so much runtime speed.

14:59 kotarak: What kind of key shortcut could I use, when r and R are already used?

14:59 For "refresh" I mean.

14:59 Chousuke: f5? :P

14:59 rlb: Chouser: OK, thanks.

15:00 Chousuke: or cmd-r if on a mac

15:00 kotarak: Chousuke: Nice suggestions! I think F5 will do for the rest and the Mac users will be featured the Cmd-R if this is the usual style.

15:01 Chousuke: well, it's what firefox and safari do

15:21 Lau_of_DK: Tell me again why we dont have import * ?

15:23 kotarak: Lau_of_DK: because it's for the sloppy guys.

15:27 Lau_of_DK: I've come across classes, not documented well enough for me to import them without having the *

15:27 rlb: Is the key order stable when writing a map? (I would guess not.)

15:27 I would guess that that's undefined.

15:27 kotarak: With array-map it's the order of insertion, IIRC.

15:31 unlink1: Am I missing some standard library macro which accomplishes this? http://dpaste.com/40596/

15:31 Or is there a more idiomatic way of doing this

15:31 kotarak: unlink1: a vector with conj?

15:32 unlink1: The idea is to chain a bunch of function calls.

15:33 kotarak: You mean like with ->?

15:34 unlink1: Yeah, except the result goes to the end of the next list, not in the second position (so that it works with e.g. reduce)

15:34 kotarak: There was a pipe macro discussed on the list. Just a sec

15:36 http://tinyurl.com/dljm75

15:37 unlink1: hmm, I thought | was an obvious name.

15:37 kotarak: First | is a shellism, then it is not a valid symbol name...

15:37 unlink1: It's not?

15:37 kotarak: No, IIRC.

15:38 unlink1: Why doesn't clojure complain?

15:38 dreish: It's allowed right now, but I think there are plans to make it a quoting character for symbols.

15:38 unlink1: oh..

15:38 kotarak: It may work now, but Clojure doesn't enforce the rules at the moment. It does not promise, that it will continue to work tomorrow.

15:38 unlink1: I guess then I'd vote for pipe.

15:39 I'm glad there's at least some discussion on the topic, and I'm not the only one looking for something like this.

15:40 kotarak: The authoritative source for what's allowed is http://clojure.org/reader

15:41 unlink1: oh, ok.

15:42 Lau_of_DK: Guys, is there a simple way in Clojure to connect to a telnet service, push in a password and a few commands and then read back the results?

15:43 rlb: I know about file-seq, but I'd actually like to generate a tree, i.e. a tree of file sizes. Is there already anything like that?

15:44 unlink1: -> and pipe indicate to me that currying would be a valuable addition to clojure ;)

15:44 rlb: (actually a "tree" of maps where the non-leaf keys are directory names)

15:45 kotarak: currying cannot handle ->. Then there is partial.

15:45 rlb: So you would have (((fs "home") "someone") "somefile")

15:45 -> file size

15:45 unlink1: No, technically not, but I think -> is just a less useful version of currying.

15:46 And partial indeed works, but I find it unwieldily verbose.

15:48 kotarak: You can also use #(foo :curried1 :curried2 %)...

15:49 unlink1: You could, but I often want to curry map and reduce with anonymous functions using #()

15:49 clojurebot: map is *LAZY*

15:49 kotarak: Then use partial.

15:51 unlink1: I wrote the pipe macro to avoid the verbosity of using partial.

16:03 rlb: Hmm, the debian package doesn't seem to include zippers.

16:09 z5h: i'm using nested loop/recur pairs to test values. when i find a passing set, i want to "break" out of all loops. can't seem to figure out how to do this. is there an example anywhere?

16:10 Chousuke: hmmh

16:10 z5h: maybe i'm doing things wrong :|

16:10 Chousuke: that sounds a lot like imperative programming.

16:10 durka42: you could always abuse the exception mechanism

16:11 fffej: I'm trying to work out how to use memoization and non tail recursive functions. My problem is that if I have a function f that calls itself, and a memoized version of f (f') then the definition of f calls f, not f'. Does that make sense?

16:11 Chousuke: yeah.

16:11 rlb: Is clojure.zip part of the normal distribution?

16:11 z5h: i'm implementing http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Deterministic_variants_of_the_test

16:11 Chousuke: rlb: yes.

16:11 rlb: Hmm...

16:12 danlarkin: z5h: sweet!

16:12 z5h: so i'm looping over values of a from a range, and values of r from another range.

16:13 Chouser: Lau_of_DK: A friend of mine has written such a thing: http://zancanda.staticcling.org/cgi-bin/gitweb.cgi?p=my-clojure.git;a=blob;f=clojure/sebold/expect.clj;h=0350e8b8565d7bae12874931648ed368528f6dc1;hb=HEAD#l4

16:13 z5h: if that test fails i know it's composite ... otherwise keep going

16:14 rlb: Ahh, I was just invoking it incorrectly.

16:14 Chousuke: hmm

16:14 Lau_of_DK: Chouser, perfekt

16:15 Chousuke: rlb: I think you could probably use for

16:16 rlb: Chousuke: to traverse the tree and generate values?

16:16 Chousuke: actually, I realized that I need a better idea of what I really want.

16:18 i.e. conceptually, I want to be able to traverse *something* and generate a tree that contains values for all the files/directories in the filesystem, and I was originally just thinking in terms of some kind of nice abstraction like map, file-seq, etc., but my initial conception of how that might translate was somewhat naive.

16:19 Chousuke: something like (every? true? (for [a (range 2, (tricky-thing n))] (and (first-test a d) (every? true? (for [r (range (dec s))] (second-test a r d)))))) ; parens may not match

16:19 rlb: I'm not sure zippers are what I want either, but they're interesting.

16:20 Chousuke: rlb: oops, I meant z5h :p

16:20 z5h: Chousuke: i need to digest that for a minute

16:20 Chousuke: rlb: clojure-contrib has some walk functions for traversing zippers. presumably trees as well :/

16:21 z5h: it's basically a direct translation of the mathematical formula

16:21 fffej: if I have a non-tail recursive function f and I memoize it, how do I ensure that the calls of f inside f will be the memoized version? I can't transform it to tail recursive (I'm assuming that recur would solve the problem by magic)

16:21 rlb: First I really need to think about what the output should look like -- (((fs "home") "someuser") "somefile") looks nice, but it's simplest incarnation doesn't provide any way for the tree to have info for non-leafs (dirs).

16:22 Chousuke: z5h: for in clojure is not a loop; it's a seq comprehension (it returns a lazy seq)

16:22 rlb: Of course you could have special terminals like (((fs "home") "someuser") :info), but I'm not sure that's what I want either.

16:23 z5h: right, so i'm i'm asking for everything to be true, it'll stop as soon as it finds something false

16:23 Chousuke: yeah

16:23 z5h: gotcha. thanks

16:24 that will actually make things a lot cleaner

16:24 :)

16:24 Chousuke: actually better would be "(every? identity ...)" since true? only returns true if the item really is the literal "true"

16:24 identity will return true for anything not nil or false

16:25 Chouser: fffej: probably easiet is to (declare foo), then def unmemoized-foo in terms of foo, then finally store the memoized verion in foo

16:26 fffej: chouser: thanks, that makes sense. I think I was trying to make something WAY too complicated :)

16:27 Chouser: you could try using letfn or something, but I've not tried that yet.

16:27 Chousuke: that way, you won't be ale to use the unmemoised version though, will you? :/

16:28 I guess that might not be a problem :)

16:28 fffej: not to me (at the moment at least!)

16:29 Chousuke: I wonder if my for beast primality test actually works. it's too simple :(

17:09 chessguy: so...i know i'm a clojure/lisp newb, but there's something i don't get about macros

17:09 i've seen a number of non-trivial programs in clojure that don't use macros (or only use 1 or 2). yet all the literature seems to indicate that macros should be everywhere

17:10 seems like a disconnect

17:10 Chousuke: rlb: hm, maybe each node could be a map, so you could attach arbitrary info? :/

17:10 chessguy: clojure itself uses macros quite a lot :)

17:11 chessguy: so it's more like macros _should_ be everywhere, and if they're not, it's because the author doesn't know any better?

17:11 Chousuke: hmmh

17:12 chessguy: not trying to pick any fights either way

17:12 just trying to understand

17:12 and i recognize it's a pretty vague question too

17:12 Chousuke: in a way they are everywhere because a large part of the core language is implemented with them

17:13 chessguy: ok, but i'm talking about non-core libraries and apps

17:13 Chousuke: macros can be used when you need a more convenient syntax for expressing a pattern that often appears in your code.

17:13 for applications, that may not be very frequent.

17:13 often you can get away with just functions.

17:14 chessguy: hm

17:14 Chouser: chessguy: that doesn't match the literature I've seen.

17:15 or my experience, what little there is of it.

17:16 I think most apps don't need very many macros, but when you need one you really do need it, and the alternative is quite painful.

17:17 Chousuke: chessguy: one common use for macros is defining a context. you pass whatever parameters are needed to set up he environment, and it expands to code that does so.

17:20 chessguy: like with-open or with-monad or with-connection (from contrib.sql)

17:22 such setup is probably technically possible to do with functions, but when done with macros you get a cleaner syntax and less anonymous function objects :)

17:23 chessguy: interesting idea

17:25 AWizzArd: offtopic, but good for Star Trek fans: http://www.youtube.com/watch?v=JGAahDeceHI&fmt=18

17:26 Chousuke: chessguy: also, clojure itself actually implements the destructuring versions of let, fn & co. as macros. the documentation says they're special forms, but that's a lie. You just can't tell because they're macros :P

17:27 ~source destructure

17:27 chessguy: Chousuke: sorry, i don't know much about destructuring. how is that related to what we're talking about?

17:27 Chousuke: ^ the actual magic function used by the macros to produce the final binding form for the real primitives. good luck trying to understand it :P

17:37 chessguy: (sorry, there was some tremendous lag) I mean the complex binding forms clojure supports in fn and let etc. (fn [[a b] [1 2]] b). due to macro magic, you can't even tell that it's not "built in"

17:38 chessguy: that's the kind of stuff macros are meant for.

17:38 chessguy: hmm

17:40 Chousuke: there's nothing really mysterious about macros. lisp code is data, so all a macro really does is take one data structure (code) in and transform it into another data structure (again, code) at compile time

17:41 interestingly, you can also "call" a macro just like a normal function by doing this:

17:42 ,(#'-> 'foo 'bar)

17:42 clojurebot: (bar foo)

17:42 z5h: Chousuke, mind taking a look at my code? still acting flakey, and I can't see the problem ... where can i post it?

17:42 Chousuke: lisppaste8: url

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

17:43 z5h pasted "prime test" at http://paste.lisp.org/display/79609

17:43 unlink1: Is there a builtin for (nth (iterate rest lst) 3)?

17:44 eee: On a complete nonsequitterr now that the last challenges with the heap are stable, I have a new operation I;m thinking of supporting to make branch-n-bound searchers work nicely

17:44 z5h: http://paste.lisp.org/display/79609

17:44 Chousuke: hm

17:44 ,(iterate rest [1 2 3])

17:44 clojurebot: :(

17:44 clojurebot: Execution Timed Out

17:44 Titim gan �ir� ort.

17:44 Chousuke: ,(take 2 (iterate rest [1 2 3]))

17:44 clojurebot: ([1 2 3] (2 3))

17:44 eee: called "cutGreater(maxOk)" . . . .everything greater will be culled from the heap

17:45 Chousuke: unlink1: I don't think so

17:46 z5h: and, of course, the algorithm is taken from http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Deterministic_variants_of_the_test

17:46 unlink1: cdddr in scheme

17:47 eee: i'll have to get some clojure examples up soon of some solutions using the heap

17:47 ... thought I'd stop in and report progress

17:47 Chousuke: z5h: isn't that or in looksprime supposed to be and?

17:47 z5h: well, if both are not equal it's composite

17:48 so if either are true, it might be prime

17:48 eee: turns out I need to sign off. sorry for the drive-by. check ya later

17:52 Chousuke: z5h: so how is it flakey?

17:52 unlink1: Why both fnext and second?

17:53 Chousuke: unlink1: second is more intuitive

17:53 fnext is probably historical baggage? :P

17:53 unlink1: Pre-1.0 sounds like a good time to cast that aside.

17:55 Chousuke: z5h: style nitpick: instead of (. Math (log n)), use (Math/log n)

17:56 z5h: Chousuke: it says 3 and 7 are prime, but 5 is not :(

17:56 Chousuke: oh, indeed

17:56 I conveniently skipped that one :P

17:59 z5h: i once spent a week debugging something at work because a university textbook i was using had an error in it's pseudocode

17:59 Chousuke: also (+ x 1), (- x 1) -> (inc x) and (dec x) respectively. but I can't figure out what your problem is :/

18:32 unlink1: What's the best way to get the current state of a var pointed to by a symbol named by a string?

18:32 I.e. something like (deref (resolve (symbol s)))) ... or is that as simple as it gets?

18:33 AWizzArd: yes

18:33 It's good that you need to be explicit about it. But you could wrap this any time into a function if needed.

18:34 Chousuke: you can replace deref with @ :)

18:37 rlb: The API docs might need a section delimiter of some kind.

18:37 i.e. outdent section headers, add some space, etc.

18:40 So are zippers a resonable approach for wholesale tree "conversion", i.e. where you're taking a tree and producing a tree with the same shape, but mostly different content?

18:40 s/resonable/reasonable/

18:40 hiredman: I believe so

18:40 actually

18:40 rlb: i.e. something like a tree "map"

18:40 hiredman: yeah

18:40 zippers are great for that

18:41 rlb: They look interesting -- probably worth learning about regardless. Here goes.

18:41 hiredman: ,(doc clojure.zip/next)

18:41 clojurebot: "([loc]); Moves to the next loc in the hierarchy, depth-first. When reaching the end, returns a distinguished loc detectable via end?. If already at the end, stays there."

18:42 rlb: So first I may need the tree equivalent of file-seq.

18:42 hiredman: ?

18:42 clojurebot: qcon slides is http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/RichHickey_PersistentDataStructuresAndManagedReferences.pdf

18:43 hiredman: clojurebot: chill out

18:43 clojurebot: Pardon?

18:43 AWizzArd: hiredman: I have seen you in the past several times doing (doc something) without the comma in front, but the bot replied anyway. Is that the bot0wner mode? ;)

18:43 hiredman: no

18:43 it is the old doc look up code

18:43 only works on core

18:43 AWizzArd: ic

18:43 hiredman: (doc next)

18:43 clojurebot: Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil.; arglists ([coll])

18:44 hiredman: (doc clojure.zip/next)

18:44 clojurebot: No entiendo

19:18 lisppaste8: z5h pasted "fixed prime test" at http://paste.lisp.org/display/79614

19:35 z5h: is there a way of making every?, map, etc run on multiple threads?

19:36 danlarkin: z5h: there's pmap

19:37 z5h: thanks

19:41 wow. i just parallelized part of my code in 10 seconds. amazing!

19:44 cads: hello all

19:46 hey, I've been using maps to represent objects with named properties, and defining functions that deconstruct these maps

19:48 replaca: cads: ok

19:49 cads: is there a more idiomatic way to work with objects with properties (in this case I have particles with mass, velocity and position)

19:50 hehe, I think I should use structs, first of all

19:50 rlb: Why does conj require a non-empty rest list?

19:50 (Am I just not thinking straight?)

19:50 hiredman: eh?

19:51 rlb: (apply conj '{1 2} '())

19:51 hiredman: ,(conj () 1)

19:51 rlb: Causes an exception here.

19:51 clojurebot: (1)

19:51 hiredman: {} is a hash

19:51 you need to conj on a key and a value

19:51 rlb: (apply conj '{1 2} '({3 4}))

19:51 is fine

19:52 hiredman: ,(conj {})

19:52 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$conj

19:52 rlb: Original application was (apply conj `{~x ~y} (map ...))

19:53 And of course I'd rather not have to check whether or not the seq passed to map is empty first.

19:54 hiredman: ,(apply conj {} (seq '()))

19:54 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$conj

19:54 hiredman: I do believe it has to do with how aply works

19:54 apply treats an empty list as no args

19:55 ,(apply + 1 2 '())

19:55 clojurebot: 3

19:55 hiredman: empty seq

19:55 I should say

19:56 rlb: OK. I'll have to reconsider.

19:56 There's probably a better way to do what I'm trying to do anyway.

19:57 hiredman: ,(into {} (map vector (range 10) (range 10 20)))

19:57 clojurebot: {0 10, 1 11, 2 12, 3 13, 4 14, 5 15, 6 16, 7 17, 8 18, 9 19}

19:57 rlb: I'm just trying to build a sorted map.

19:57 (from individual pairs)

19:57 hiredman: ,(into (sorted-map 1 1) (map vector (range 10) (range 10 20)))

19:57 clojurebot: {0 10, 1 11, 2 12, 3 13, 4 14, 5 15, 6 16, 7 17, 8 18, 9 19}

19:58 rlb: OK, that sounds about right. Thanks

20:00 hiredman: (class [1 1])

20:00 ,(class [1 1])

20:00 clojurebot: clojure.lang.LazilyPersistentVector

20:00 hiredman: ,(ancestors (class [1 1]))

20:00 clojurebot: #{java.lang.Comparable java.util.concurrent.Callable clojure.lang.AFn java.util.Collection java.util.RandomAccess clojure.lang.IPersistentStack clojure.lang.IPersistentVector clojure.lang.IObj clojure.lang.APersistentVector clojure.lang.IFn clojure.lang.Reversible java.lang.Runnable java.lang.Object clojure.lang.Associative clojure.lang.Sequential clojure.lang.Counted clojure.lang.Streamable java.io.Serializable java.util

20:01 rlb: Oh, wait, does into flatten?

20:01 hiredman: nope

20:01 rlb: hmm, must be doing something wrong then.

20:01 hiredman: well, what do you mean by flatten?

20:02 rlb: I'm trying to maintain a tree of sorted-maps.

20:02 s/maintain/build/

20:02 hiredman: into takes a collection and a seq, and poors the seq into the collection

20:02 ,(into (sorted-map) '([a b] [c d]))

20:02 clojurebot: {a b, c d}

20:03 hiredman: so if you have map generate a seq of two element vectors, you can easily make a sorted-map

20:04 ,(instance? java.util.MapEntry [1 1])

20:04 clojurebot: java.lang.ClassNotFoundException: java.util.MapEntry

20:04 rhickey: New example at: http://clojure.org/refs

20:04 hiredman: ,(drop 10 (ancestors (class [1 1])))

20:04 clojurebot: (clojure.lang.Reversible java.lang.Runnable java.lang.Object clojure.lang.Associative clojure.lang.Sequential clojure.lang.Counted clojure.lang.Streamable java.io.Serializable java.util.List clojure.lang.IPersistentCollection java.lang.Iterable clojure.lang.Obj clojure.lang.IMeta clojure.lang.Seqable)

20:06 hiredman: ~def c.l.Streamable

20:10 Chouser: I've got a series of IO steps to do. If an error is encountered on step n, I really shouldn't attempt to do step n+1.

20:11 AWizzArd: makes sense :)

20:11 Chouser: currently these are in a lazy seq, and I'm using things like 'for' and 'split-with'

20:12 the correctness of this depends on none of the lazy seq operations going too far by even a single step. Is it wrong to depend on this?

20:12 Should I use delays or thunks in a vector instead, such that I can be more explicit?

20:15 hiredman: so you are asking if it is ok to depend on lazy seqs and lazy-seq consuming functions being lazy?

20:17 rlb: hiredman: thanks -- that worked, I just wasn't doing what I thought I was doing.

20:17 (took way longer than it should have -- still not used to clojure vs scheme/cl)

20:26 lisppaste8: rlb pasted "first-pass, trivial fs-tree" at http://paste.lisp.org/display/79616

20:26 rhickey: Chouser: as long as you can detect the error and stop pulling, you should be able to rely on the fully lazy seqs

20:27 rlb: hiredman: I imagine that needs work, and could perhapd me more idomatic, but it'll do for the moment.

20:27 s/perhapd me/perhaps be/

20:27 hiredman: the what and the which now?

20:28 rlb: hiredman: I just pasted the thing you were helping with.

20:28 hiredman: oh

20:28 rlb: (fs-tree (new java.io.File "foo")), for example

20:29 hiredman: irc client is having rhickey and lisppaste8 the same color

20:29 rlb: It just creates a tree of sorted maps representing the java file objects.

20:29 hiredman: irc client is having rhickey and lisppaste8 the same color

20:29 erp

20:30 interesting

20:32 if you are planning to use zippers, I think it would be possible to generate a zipper of a filestem without an intermediate representation

20:33 rlb: hiredman: interesting -- is that using zipper?

20:33 hiredman: yeah

20:33 rlb: Argh -- didn't pay attention to that.

20:33 hiredman: but I dunno how useful a zipper over a a filesystem would be

20:34 rlb: hiredman: how would that work? Does it memoize, or would it constantly refer to the fs?

20:34 hiredman: filesystems tend to be mutable and zippers are not

20:34 rlb: hiredman: in this case it might be fine -- the assumption is that the fs is static.

20:34 hiredman: rlb: you provide zipper with the functions it needs to generate a zipper structure

20:35 ,(doc clojure.zip/zipper)

20:35 clojurebot: "([branch? children make-node root]); Creates a new zipper structure. branch? is a fn that, given a node, returns true if can have children, even if it currently doesn't. children is a fn that, given a branch node, returns a seq of its children. make-node is a fn that, given an existing node and a seq of children, returns a new branch node with the supplied children. root is the root node."

20:35 rlb: hiredman: right, but is that approach likely to result in a lot of fs references for repeated traversals?

20:35 The other approach won't.

20:35 (though that may not be critical)

20:35 Actually, I might want both...

20:36 (fs-map sometimes, and a (zipper...) based result other times)

20:36 Chouser: rhickey: ok, thanks.

20:36 hiredman: the zipper functions are not called when you tranverse the tree

20:37 the zipper functions are used to generate a zipper data structure on top of the tree, which is traversed by the various utility functions

20:38 ,(-> '(a (b c) d) clojure.zip/seq-zip)

20:38 clojurebot: [(a (b c) d) nil]

20:38 hiredman: ,(-> '(a (b c) d) clojure.zip/seq-zip next)

20:38 clojurebot: (nil)

20:38 hiredman: ,(-> '(a (b c) d) clojure.zip/seq-zip clojure.zip/next)

20:38 clojurebot: [a {:l [], :pnodes [(a (b c) d)], :ppath nil, :r ((b c) d)}]

20:40 rlb: FWIW one of the motivations here is that I wanted to be able to create a structure that would let you quickly answer particular questions about files in a (potentially very large) fs without having to store the full paths in a giant hash table. For one fs here a plain text file containing the full paths is about 200MB. Filenames without prefixes take up ~67MB.

20:40 Of course, I'm not sure how that'll translate to clojure's in-RAM use.

20:41 To some extent, I'm just using this as an excuse to learn more about clojure.

20:41 hiredman: hmm

20:43 rlb: Imagine for example, you want to be able to reasonably quickly retrieve the fs size for any file on the filesystem -- also assume that the data is being sent from another machine (i.e. even if asking the fs was fast enough, you can't).

20:44 hiredman: ,(-> `(1 ~(iterate inc 0) 2 3 4) clojure.zip/seq-zip clojure.zip/next clojure.zip/node)

20:44 clojurebot: 1

20:44 hiredman: I guess zippers can be lazy

20:45 rlb: Anyway, you could also cram all the data into sqlite or a sandboxed (or systemwide) postgresql, but that may be more expensive, and it's presumably not as easy to manipulate from clojure.

20:46 hiredman: ,(-> `(1 ~(iterate inc 0) 2 3 4) clojure.zip/seq-zip clojure.zip/next clojure.zip/next clojure.zip/next clojure.zip/node)

20:46 clojurebot: 0

20:49 rlb: When I get time, I'd still like to look in to the possibility of #!/usr/bin/clojure support.

20:58 hiredman: rlb: everyone seems to have rolled their own scripts for launching clojure and for shebang support

20:58 rlb: hiredman: oh, well, then I suppose I don't need to do it too, but it'd be nice if there was standard support.

20:59 Debian has a /usr/bin/clojure, but it's not what I'd want.

21:08 Is (dorun (map f x)) the apropriate substitute for something like for-each?

21:10 hiredman: doseq is more foreach like

21:11 ,(doseq [i (range 10)] (print i))

21:11 clojurebot: 0123456789

21:12 rlb: hiredman: so you'd have something like (doseq [x items] (f x))?

21:13 I tried that fs-map on the whole fs -- java went up to over 600MB before I stopped it. I'm now trying a trivial "how fast can java even just dump the file names in an fs" test.

21:13 (want to know if I'm wasting my time)

21:14 hiredman: well, the main thing is maps are not lazy and you are making a map, so everything is getting loaded

21:15 rlb: hiredman: right, but not in the current test.

21:15 Changed it to just (prn (.getName file)) and use dorun for the sub-dir map.

21:18 So far the simpler version is taking about 250MB, and doesn't appear to be going very fast. For comparison, find can do the same job in 5 seconds with a hot cache.

21:19 Perhaps there's some better way to do what I'm trying to do in java, or perhaps java's not going to be a reasonable choice (and best to find out now).

21:21 kadaver: http://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311#

21:21 noone has any comments on general style of that mp3player?

21:22 im really wondering if it can be done in a cleaner more clojure-ish way

21:22 because i feel like i would have been better of writing it in C even...

21:23 cads: where can I find a tutorial that shows me how to overload the + operator so that it works different for different types of arguments?

21:24 kadaver: can you eval things here with clojurebot?

21:24 cads: not sure if you can overload + but the normal way s to use multimethods

21:24 cads: like I'd like it to be real-vector addition when I give it vectors in r^n, and set union when I give it two sets

21:28 kadaver: do you really do that often enough to bother ?

21:28 (defmulti + ...

21:29 but im not sure f you can us emultimethods in buitins...try it and see

21:31 rzezeski: Q for the Emacs gurus: Is there a parallel to Vim's before next/previous occurrence movement command. For example, if I want to delete everything up-to the next double quote I could do dt" in Vim. Is there something similar in Emacs w/o writing a custom command?

21:32 and without using viper/vimpulse mode

21:36 cads: kadaver, I find symbolic operators are a strong mnemonic for me

21:38 lots of times we can define cool structures with a few custom operators and some named functions defined mainly in terms of those operators

21:44 kadaver: user=> (defmulti + (fn [x y] (class x)))

21:44 java.lang.Exception: Name conflict, can't def + because namespace: user refers to:#'clojure.core/+ (NO_SOURCE_FILE:1)

21:44 i was afraid of that

21:44 so not sure if you can

21:44 user=> (defmulti ++ (fn [x y] (class x)))

21:44 #'user/++

21:44 perhaps?

21:45 where is set/union?

21:49 cads: I think that would work

21:53 kadaver: then you use defmethod to declare what shoud happen

21:58 DMisener: /help

21:59 !help

22:01 kadaver: HELP!

22:02 rhickey_: ,(doc clojure.set/union)

22:02 clojurebot: "([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets"

22:02 barkley: just wanted to tell stuart that i bought the book because the mobi format

22:03 reading clojure on the kindle rocks

22:04 anybody doing any video processing with clojure?

22:05 I guess the real question is how to do video processing without being tied to windows COM libs

22:08 kadaver: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=4543#a4543

22:08 ^^ whats wrong with that? i didnt use mutimethods a for a long time, dont remember hwat im doign wrong

22:15 dliebke: kadaver, try this: (defmethod ++ clojure.lang.PersistentHashSet [a b] (clojure.set/union a b))

22:16 kadaver: its for cads anyway

22:17 http://hpaste.org/fastcgi/hpaste.fcgi/view?id=4544#a4544

22:17 ^^ cads, mutimethod and example

22:17 http://clojure.org/multimethods

22:18 cads: hey, I've created a numerical vector library, but one thing that I noticed is that the way I've written it it'll take and two sequences, and if those sequences have numbers as their elements, it can do numerical euclidean vector operations and return a sequence in general

22:18 but I don't know if it'll return a vector or a set or a list

22:19 kadaver: how do you dispatch on 2 values?

22:20 cads: most functions are implemented as maps

22:20 kadaver: vec

22:20 how do you eval here?

22:21 clojurebot: eval?

22:21 clojurebot: eval is evil

22:21 kadaver: clojurebot: eval

22:21 clojurebot: eval is DENIED

22:21 cads: ,(vec '(1 2 3))

22:21 clojurebot: [1 2 3]

22:21 cads: ,(vec #{1 2 3})

22:21 clojurebot: [1 2 3]

22:21 cads: ,(vec {1 2 2 3})

22:21 kadaver: ,(vec {1 2 3 4})

22:21 clojurebot: [[1 2] [2 3]]

22:21 [[1 2] [3 4]]

22:22 cads: so I'd just want to write all my functions and make sure they call vec on the answer they create

22:22 barkley: i'm not much of a programmer, but isn't everything really event-based?

22:23 hiredman: nope

22:23 barkley: hiredman: in modern programming, we do database, web servers, guis....why isn't everything event-based?

22:23 clojurebot: why not?

22:23 barkley: oops. wrong nope?

22:23 hiredman: not everything is a gui

22:23 barkley: didn't say that

22:24 hiredman: I didn't say you did

22:25 batch programming (non-interactive processing jobs) generally don't make sense as events

22:25 for example

22:26 cads: ,(take 10 (vec (repeatedly inc 0)))

22:26 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$repeatedly

22:26 barkley: true, and how much "batch" programming are we doing thes days...as in, "let's run this payroll program at 3am"

22:26 cads: ,(take 10 (vec (repeatedly rand)))

22:26 clojurebot: java.lang.OutOfMemoryError: Java heap space

22:26 hiredman: cads: vec is not lazy

22:26 barkley: a lot

22:26 cads: just found that out :)

22:26 barkley: hiredman: not really

22:27 hiredman: but even in the case of batch programming, they're still events involved

22:27 hiredman: barkley: for example MapReduce/hadoop stuff

22:27 cads: is there a function that takes a sequence and returns either a persistent vector or a lazily persistent vector?

22:27 barkley: hiredman: well, i guess i disagree with you...we'll leave it at that

22:28 hiredman: ,(class [])

22:28 clojurebot: clojure.lang.PersistentVector

22:29 kadaver: cads: doesnt most vectorn functions retuen a double or int anyway?

22:29 hiredman: ...

22:29 cads: kadaver, are you a little tipsy over there?

22:29 kadaver: ,(take 10 (vec (repeatedly #(inc 0))))

22:29 clojurebot: java.lang.OutOfMemoryError: Java heap space

22:29 kadaver: tipsy?

22:30 barkley: we're programmers, we're always tipsy;)

22:30 cads: barkley, events are cool, but they're not that great of a model of computation and concurrency, I don't think

22:30 barkley: cads: hmm...i just see it as higher-level fundamental though

22:31 cads: isn't a post/get an event?

22:31 cads: plus, there are many different frameworks for that

22:31 kadaver: , (vec 1)

22:31 clojurebot: java.lang.Exception: Unable to convert: class java.lang.Integer to Object[]

22:31 barkley: cads: granted i'm not a http programmer guru

22:31 cads: consider the philosophies of communicating serial processes, or the Pi calculus

22:31 barkley: cads: that's my point

22:32 kadaver: , (defn pure [x] [x]) (pure 10)

22:32 clojurebot: DENIED

22:32 barkley: cads: you know anything about dataflow?

22:32 kadaver: , (let [pure x [x]] (pure 10))

22:32 clojurebot: java.lang.IllegalArgumentException: let requires an even number of forms in binding vector

22:32 barkley: here's my deal..i've never felt comfortable with OO programming...too much state...too much spaghetti internals in objects

22:33 OO "gurus" tell us static methods are bad? why?

22:33 cads: well you're here safe in a more functional world

22:34 for event type stuff, there are agents

22:34 barkley: cads: just bought the book, i'll definitetly get to that. thanks!

22:34 cads: yeah, agents can easily be used for event based modelling

22:35 barkley: cads: that's all i really was curious about...if we can at least model events in a flexbile language like clojure - like obviously we can

22:35 i think i'm brain-damaged by OO

22:35 well, maybe not....i never bought into it in the first place

22:36 kadaver: cojurebot: OO?

22:36 clojurebot: OO?

22:36 clojurebot: OO is to programming what astrology is to astronomy

22:36 cads: heh, I think I'm brain damaged by haskell, whenever I see "event" or "state" I say "get it away from me, put it in a monad!"

22:37 kadaver: cads: where do you study?

22:37 barkley: i don't compare event and state

22:37 event seems fundamental, state seems very hackish for most purposes

22:38 cads: event and mutable state go hand in hand

22:38 barkley: i'm sorry cad...i was talking dataflow

22:38 you guys ever studied dataflow languages?

22:38 cads: not sure what you mean

22:39 why does an event have to be with mutable state?

22:39 i guess i'm getting at dataflow

22:39 more of a real engineering perspective

22:39 cads: objects only ever flag events when their internal state reaches a certain point

22:40 barkley: but that's irrelevant to functional languages or state

22:40 or maybe i'm missing something

22:40 at our fundamental level, we have callbacks

22:40 we register a callback and it happens

22:41 sorry if i'm a loser on this

22:41 i just always question things...like OO

22:41 hiredman: if you think callbacks are fundamental I recommend you search the ia32 isa for a register callback instruction

22:42 cads: wouldn't dataflow language make it harder to deal with a bunch of state mutating and changing which way the data has to flow?

22:42 barkley: cads: isn't that the point of functional languages?

22:43 cads: dude, i'm not expert, i'm just trying to figure things out

22:43 cads: those prefer to deal with streams of data and to have little changing state

22:43 barkley: we have state change

22:43 let's not try to blow that off

22:44 cads: barkley, I was wondering if you were coming from a dataflow language background

22:44 barkley: no, no

22:44 i thought you might know something:)

22:44 isn't an exception a higher-order event?

22:45 cads: lol, I don't think I'll like exceptions till I read a paper that shows me how to write a formula for them

22:45 I don't think exceptions belong in my programs

22:46 barkley: that's why we need Some-Nothing?

22:46 as in many other fucntional languages?

22:46 cads: oh, have you followed the bottom discussion?

22:46 barkley: no

22:46 i'm new

22:47 cads: I wouldn't be against a bottom type

22:47 barkley: it's insanse that in C# 3.0 extensions that i get caught in godamn chain with a null

22:48 nulls should be dealt with gracefully

22:48 i guess..like i said i'm not much of a programmer

22:48 cads: hehe, your questions are all over the place

22:49 you just need to focus and study

22:49 barkley: all i know is that OO kindof sucks

22:50 for the time being i'll use clojure for mysql database munging

22:50 cads: look at this site, so far I like it better than stuart halloway's actual book, athough the book is more conversational

22:50 http://java.ociweb.com/mark/clojure/article.html#References

22:50 barkley: cads: been there...have it open

22:50 ...open in tab

22:50 i bought stuart's book last night because it's on mobi format

22:50 so i can read it on my kindle

22:50 cads: isn't the site great?

22:50 barkley: Stuart!...i bought because of kindle!

22:51 mark lives in st. louis with me

22:51 cads: I want one of those damn things so bad

22:51 barkley: never met him..but i reallly appreciate that great intro

22:51 expensive as hell

22:51 relative

22:51 mom gave it to me for christmas

22:52 the only thing that sucks is that pdf conversion bites for programming type texts

22:52 and kindle2 doesn't resolve that

22:52 cads: anyways, code some code and when you've built something complicated enough, put it in agents and make a bunch of them interact or something :)

22:53 barkley: cads: dude, the reason i come to clojure is because of sequence unification and REPL

22:53 cads: it's good stuff

22:53 barkley: cads: the concurrency will come later

22:53 how can you develop without a REPL?

22:54 it's insanse...

22:54 i do little console projects in C# 3.0

22:54 cads: yeah, other languages are painful now

22:54 barkley: and OO screws it all up anyway

22:55 cads: OO is okay, for happy joyous and light OO, check out ruby or smalltalk

22:55 barkley: i'm just happy that enclojure rocks because i despise emacs....love VIM....haven't checked out Gorilla

22:55 i don't think OO

22:55 i think in data

22:55 and how i can TRANFORM it

22:56 that's the whole point of programming

22:56 not this boiler-plater....messaging...gobbly-gook

22:56 cads: were you wondering about higher order functions earlier?

22:56 barkley: no, i know i can simulate anything i want with closures

22:56 maps..whatever

22:56 OO-wise

22:56 here's my deal

22:57 ...

22:57 and actually my philosophy

22:57 OO is total premature-optimization

22:57 you scaffold this shit, and then you tear it down...AKA refactoring in the OO world

22:58 another rant on OO....the world is NOT OO

22:58 the world is data and functions that work on data

22:59 sorry for the rant

22:59 cads: lol

23:00 barkley: when i saw rich say "I'm trying to get away from OO"...I knew i had to check it out

23:00 cads: yeah, we don't really talk too much about 'OO' here, you seem to have a real chip on your shoulder about it

23:01 just chill out, relax, enjoy the anonymous and generic functions :)

23:01 barkley: cads: professionally, i started doing Linux programming in the mid 80's and my boss was settled on C++...i wasn't happy with "premature optimization"

23:01 benatkin: I don't hear erlang people bash OO, and so far I haven't heard any clojure people bash it either.

23:01 barkley: "where does this damn method belong"?

23:02 benatkin: i'm bashing OO

23:02 benatkin: all i know is what i see

23:02 benatkin: and i didn't bash Erlang

23:02 cads: benatkin: I'll bash java and c++ oo, but pure I have some respect for pure OO theory

23:02 barkley: but...we have multi-methods!

23:02 so we don't need this retarded tree

23:02 benatkin: yeah...that's what I've seen with erlang

23:03 barkley: the world is not a tree

23:03 benatkin: someone did an artilce "Why erlang isn't especially OO"

23:03 barkley: benatkin: saw it

23:03 benatkin: I thought that was a nice take on the issue

23:03 barkley: actually..

23:03 cads: barkley, we'd be upset at OO if they could do something we couldn't do

23:03 barkley: Paul Graham did "why arc isn't especially OO"

23:03 cads: but we can do a great deal they can't, easily

23:03 barkley: or not at all

23:04 benatkin: I used to bash OO, but that distracted me, big time

23:04 barkley: i want OO when i need OO damnit!

23:04 if i don't need it, then don't force it fucking on me!

23:04 benatkin: so I don't do that any more. I just try to learn about it and pick and choose what OO techniques I like

23:04 cads: if you're bashing OO that means your brain's still thinking in terms of objects, and hating it :D

23:04 barkley: cads: no brother, i never drank the kool-aid

23:05 cads: so i'm at home in clojure:

23:05 and i'll be hiring someone soon

23:05 i don't want anybody that can't handle lisp

23:06 cads: hey barkley, does enclojure provide namespace completion in its code completion feature?

23:06 barkley: cads: completion is a bit flakey

23:06 clojurebot: 1

23:06 barkley: i need to contribute

23:06 i'm used to VS completion though

23:06 which i love

23:06 verec_: barkley: do you have a few multimethods uses that you wouldn't be able to do in "standard" java, nd would care to share?

23:07 barkley: and java IDEs don't do off the shelf, which is "i know what your trying for and i'll pop up"

23:07 rzezeski: barkley, I hate to break the news to you, but Clojure was bootstrapped in Java :) OO strikes again!

23:07 barkley: verec_: it's the case of i want to dispatch on what i want to dispatch on

23:08 verec_: sure. Example?

23:08 barkley: verec_: no, not off the top of my head, i'm doing a c# 3.0 chromakey app right now....sorry

23:08 i want to dispatch on what i want to dispatch on though?

23:09 more dynamic typing than anything

23:09 i reverse engineer classes based off a mysql database

23:09 cads: verec, I dunno, I used OO in a environment where it was pretty friendly, and miss some of the encapsulation features from there sometimes

23:10 barkley: here's the problem

23:10 verec_: cads, can you be more explicit, please?

23:10 barkley: everytime i have to hand-twiddle the models because they're on the same model but different databases, so my code is fubar with a statically typed database

23:11 verec_: bottom line is that i don't think OO

23:11 Nice had predicate-dispatch which was "nice"

23:11 poor "nice"

23:12 love predicate-dispatch

23:12 verec_: barkley: but you would be able to do this with any dynamic OO stuff like CLOS in CL, right? What is, accoring to you, so poerwul, useful regarding clojureMMs?

23:12 barkley: verec_: i don't wan to be contrained by a tree hierarchy

23:13 the world is not trees

23:13 our models of the world is not a tree

23:13 rzezeski: The thing is, "OO" can mean so many different things. To some it just means Java/C++/C#/etc, to others it means Smalltalk/CLOS. No one agrees on a canonical OO. To dismiss it in whole is probably a little rash. There are things to be gained in OO, and things to dismiss, just like anything else.

23:13 verec_: I understand what you don't want. That's what toy do want I'm interested to learn about ... :D

23:13 barkley: it's a graphy

23:13 cads: verec, on the one hand I'd like to write a function that takes any of a combination of types of objects and can operate them together, say a multiplication function that can take either two numbers, a number and a vector, or two vectors. In OO with class hierarchy we wonder "do we give the function to the vector class, or the number class". In clojure we just have a generic function. But in ruby, where I learned OO, it was very helpful an

23:13 d easy to find out what kinds of methods were applicable to an object, and to create objects with useful collections of methods that you could add to or modify. in clojure getting a grasp of a type's useful methods is harder for me

23:14 barkley: could we macro predicate-dispatch ?

23:14 or do we need that with clojure?

23:15 cads: I think in java or c++ we have a harsh class based hierarchy OO with multiple inheritance that can make things very complicated

23:15 barkley: my point is that, i don't think in hierachiers

23:15 i think in data and functions

23:15 cads: in ruby we have a single inheritance tree, plus classes can have modular features mixed in if they implement interfaces for the modules to hook into

23:15 barkley: and then LATER ON i want to dispatch on it

23:16 another case of where OO is premature-optimizaation

23:16 verec_: Let's get pratctical here, in a situation where you have to deal with a pre existing java framework of some king (eg: Swing) and what to intermix your own MM based stuff. What's your approach?

23:16 barkley: why is refactoring so big in the OO world? think about that?

23:16 cads: in other languages we just have object prototypes that are just lone objects that are not part of a hierarchy or inheritance

23:16 rzezeski: cads: I'd agree, I think a big reason languages like Ruby/Erlang/Haskell/Python/Cojure/etc have had such a surge lately is just for this reason. They impose restrictive rules that are hard to get around. At the end of the day all these languages are turing complete, it's just some let you get a particular job done faster than others.

23:17 barkley: rzezeski: exactly

23:18 verec_: barkley: I hope you see how "change method signature" van be useful, OO or not, ie even with "plain" functions?

23:18 barkley: rzezeski: yes, we can "greenspun" our way around it int the OO world, but we need tools to do it

23:18 cads: I like clojure but I just might have to experiment with things like maps that encapsulate object properties and functions

23:18 barkley: verec_: i just brought up the tools point

23:18 cads: hah, for that matter, I might have to start messing around with agents

23:19 barkley: and ti's just ugly with all that class boilerplate

23:19 cads: c'mon barkley, enough bashing, instead of all that bashing you could be writing code or getting head, like right now :)

23:19 barkley: listen, i'm not saying OO is useful...i'm saying it's been snake-oil for 20 years now

23:19 s/useful/not usefu/gc

23:20 rzezeski: nothing is a panacea though, languages aren't created and kept around on a whim, there are reasons why languages like C/Bash/Tcl/VB/Java/Smalltalk/Perl are around. There is no one size fits all

23:20 barkley: here's the thing for me

23:20 we talk about agaile

23:20 agile

23:20 how can you be agile without a REPL?

23:20 and OO by its nature makes REPL development weird

23:21 rzezeski: are you saying Agile hinges on the prescence of a REPL?

23:21 barkley: no

23:21 it makes it a helluva lot better though

23:21 verec_: barkley: are you saying that people couldn't do CLOS at the REPL in CL ????

23:21 rzezeski: sure, but Agile is not about any particular process, it's about a mind set

23:21 cads: I crash my repl too often to do development in it :D

23:22 barkley: CLOS is generic-functions

23:22 rzezeski: the language and tools don't matter nearly as much as the mindset

23:22 barkley: much easier

23:22 cads: I'll be like "fuck! why didn't I write that last bit in a file"

23:22 and then have to set up the environment again by hand, that's miserable

23:22 verec_: CLOS is gf + objects ... at the REPL ...

23:23 barkley: my whole point is that data does not belong with classes

23:23 bottom line!

23:23 it's wrong

23:23 no matter who says what

23:23 rzezeski: You can give a Clojure REPL to a group of monkeys, and guess what, you'll have nothing to show for at the end of the day except maybe some monkey poop on the keyboar

23:23 verec_: If data doesn't "belong to class" what does it belong to? How do you package a set of related items together?

23:24 barkley: modules

23:24 another example of wrong OO premature-optimization

23:24 cads: verec_: hehe, that's a good question.. how does clojure do it?

23:25 barkley: cads: we don't do OO?

23:25 verec_: What is your definition of a "module" ? how do you see the difference between it and a "class"? What is the "extra weight" that you'd carry in a class that you wouldn't in a "module" ?

23:25 barkley: we got private which is defin-?

23:25 rzezeski: and my point is...many great people have built many great programs in many different languages and paradigms. The language and semantics don't matter nearly as much as the people using them. After all, it's just a way of holding a dialogue with the computer.

23:25 barkley: verec_: that's the big problem...there's impedance mismatch with the type "class" and a "module"

23:26 and i'm sick of this non-static bigotry

23:26 verec_: barkley: what is inside any of your module? Care to give an example?

23:26 barkley: verec_: all my statics

23:26 VB does it right

23:26 unlike C# with their retarded static classes

23:27 cads: verec_: when I think module I think of some collection of functions that might be instantiated based on special parameters when the module is first instantiated

23:27 barkley: and still have to declare everything static

23:27 static should bge the default

23:27 not the other way around

23:27 verec_: by "statics" you mean what exactly? globally accessible stuff? Some "scope protection"? What exactly?

23:27 barkley: global?

23:27 rzezeski: berkley, when's your birthday? I'm going to send you a Bertrand Meyer book :)

23:27 barkley: there are no bloals?

23:28 rzezeski: i don't agree with him

23:28 rzezeski: haha, who does, he's French (j/king French people, I love you all)

23:28 barkley: well, Meyer is better than most OO, but he's still wrong

23:28 cads: verec_: clojure seems to have namespaces instead of modules, where in each namespace you have a collection of vars that are interred there and might be acessible publicly

23:28 barkley: that's why i hate him;)

23:29 cads: are namespaces first-class in clojure?

23:29 barkley: cads: yes

23:29 well...

23:29 hmm

23:29 verec_: cads, are you saying that clojure namespaces is what barkley is referring to as "module" ?

23:29 barkley: i'm not qualified to make that assertion of "first class"

23:29 cads: verec_: I don't know what kind of module barkley is referring to, and maybe he doesn't either :)

23:30 barkley: can a brother just write some code bottom up AND THEN decide if he needs OO?

23:30 cads: verec_: I'm trying to contrast a module from languages like haskell or ML, with what we have in clojure, which seem to be its namespaces

23:30 barkley: see, ML has freaky-ass module things that are powerful

23:31 or the ML family , including Ocaml

23:31 cads: and even haskell lets you instantiate whole models based on parameters

23:31 verec_: barkley: either you have mutable state or you don't. If you do, how do you package that mutable state into a consistent bag of bits?

23:31 barkley: verec_: that's the whole point

23:32 verec_: i guess i don't like the whole "class" concept

23:32 it's just wrong

23:32 verec_: Yes, and your point is what exactly? I'm getting lost ....

23:32 barkley: oh geez

23:32 why do we have to go through hoops to get static methods

23:32 or why does "the community" tell us not to static methods?

23:33 cads: verec, OO bad, groupthink bad, no use OO, evar.

23:33 I think that's the lesson

23:33 barkley: ok, in static methods in Java or C# how do they hinder testing?

23:33 cads: what's a static method?

23:33 verec_: barkley: it is fine not to like teh class concept. the question is: what do you use instead? how do you package related items together? Modules? What is inside any such a module that wouldn't go into a class?

23:34 barkley: it's retarded that i have to concept my funcs in a namespace and a class if they're static

23:34 java is horribly wrong in that respect

23:34 C# 2.0+ did the static class which was done horribly wrong

23:34 cads: verec_: how do you encapsulate a collection of generic functions into a class?

23:34 barkley: which i busted one of the C# degners on

23:35 rzezeski: where do they go then? Global lookup table?

23:35 barkley: no, no

23:35 we're just talking about a fucking namespace

23:35 why is so damn hard

23:35 i don't want "object instances"

23:35 cads: verec, it seems that encapsulating generic functions in a way that meaningfully documents how you can use those functions... is tough

23:36 verec_: barkley: java's static methods are just namespace organisation. that's all. "static" methods do not really belong anywhere other than the namespace (java package + enclosing class) that declares them. It just mostly naming, not much else, right?

23:36 barkley: so in dotnet i have to wrap everything up in a namespace and a static class

23:36 verec_: just said that

23:36 can a brother just his work done without ceremony

23:36 ?

23:36 at least i get to work in C# 3.0

23:37 i feel bad for Java people

23:38 verec_: barkley: I do not understand the fuss you're making about all this. I still want to see some code that is "better" accoriding to you in one case as opposed to the other.

23:38 barkley: well, at least i can use anyt tool i want

23:38 verec_: are you freaking kidding me?

23:38 cads: blahrg, your negative energy is cramping my evening berkley, what do you wants us to help you with?

23:39 learn lisp, be enlightened and float above these concerns and peeves

23:39 barkley: cads: have you been drinking?

23:39 cads: no, man, it's just... this is a clojure channel, and we've been talking OO for like an hour

23:39 isn't that depressing?

23:39 barkley: cads: i'm trying to explain to verec_ why we don't buy into the OO hype

23:40 thank you

23:40 verec_: who is *we*... Please do not include me, ok?

23:40 barkley: not you

23:40 brother, believe in what you want

23:40 i just never bought into OO hype

23:40 to each his own

23:41 cads: anyways, man, I'm gonna smoke a doob, and then I'll get back here an say "high", and then I'll go write some test cases for my damn particle simulator :)

23:41 barkley: in clojure?

23:41 cads: damn right

23:41 hate test cases :P

23:41 danlei: barkley: you're talking about OO all the time, but your criticism only fits a certain kind of OO (javas single-dispatch, put-it-all-in-a-class kind of OO). it doesn't fit CLOS for example, where you organize data in a classes, but have generic functions working on that data.

23:41 barkley: doing some bongs and writing clojure is a good thing:)

23:42 good deal bro. good talking to you cads

23:43 verec_: i just don't want to debate OO

23:43 verec_: sorry friend

23:43 verec_: there's nothing to debate really

23:43 cads: danlei, I've been thinking of using something more powerful than structmaps to encapsulate a particle's identity and properties, for a little particle simulator I'm writing

23:43 verec_: barkley: great! Let's get back to clojure then!!! :D

23:43 barkley: verec_: cool friend:)

23:44 what kind of simulator you working on cads?

23:44 i'd like to do my chromaky video in clojure

23:45 verec_: cads, what's missing from structmaps that you need for your simulation?

23:46 cads: guys, what can I use that's more powerful than doing (defstruct particle :mass :charge :pos :vel)? for one, with that I have to def custom accessor functions and generator functions, instead of having them defined in a semi-automatic way

23:48 verec_: cads, a structmap is a map. and in clojure any map is a _function_ of its keys, so you do not need accessors unless you want thme explicitly. What do you want accessors for?

23:49 cads: well they're supposed to be faster

23:50 kadaver: anyoen know of a code review forum?

23:50 verec_: Doesn't this sound a bit like .... premature optimization? where is your bottleneck? what have you _actually measured_ ??

23:50 kadaver: i have a 400loc mp3player that id like commetns on

23:50 written in clojure

23:51 cads: hehe, I like premature optimization, you're thinking of the other guy

23:51 rzezeski: kadaver, you could put it on http://paste.lisp.org/ and then post to the Clojure group

23:51 verec_: cads, Is your simulator in any kind of working state at the moment?

23:52 cads: no, just the vectors and the particles and be built and operated on with simple operations

23:52 right now I'm writing particle operations

23:52 let me give an example

23:53 right now I've been defining my functions like (defn grav [{a_m :mass a_p :pos} {b_m :mass b_p :pos}] (* a_m b_m (inverse-square a_p b_p)))

23:55 verec_: So you are passing *two* map arguments to your grav function? Why not a single structmap?

23:56 cads: well the grav takes two particles, each represented by a structmap

23:56 verec_: ok, then ie each of your particle is already a struct map you could pass them as such, and destructure inside grav? What's wrong with that?

23:57 cads: actually, I'm not too displeased with that

23:57 I wish I could make the destructuring implicit and save on some line noise

23:58 barkley: cads: i hear that alot

23:58 cads: "destruciting"

23:58 verec_: cads. you can't really get around the fact that you need to have all the operands available to your body, right?

23:58 barkley: what does that mean

23:59 a map into a list?

23:59 just grasping at straws here

23:59 rzezeski: barkley, you know anything about pattern matching in Haskell? It's something similar.

23:59 verec_: barkley destructuring means pulling the _contents_ of some data structure bit by bit, only extracting those elements that are relevant

Logging service provided by n01se.net