#clojure logs

2009-05-03

00:39kadaver_http://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311
00:39kadaver_^^ comment on my mp3player please
01:19eee,(as-str '3)
01:19clojurebotjava.lang.Exception: Unable to resolve symbol: as-str in this context
01:20eee,(clojure-contrib.java-utils/as-str '3)
01:20clojurebotjava.lang.ClassNotFoundException: clojure-contrib.java-utils
01:22replacaeee: I don't think clojurebot knows about contrib
01:24eeeoh ok
01:24eeei don't know the as-str functionality
01:25eeebut I was wondering how it is different from str
01:25eeeand is "as" like the english word 'as' or an abbreviation for something?
01:28replacafor things like symbols, it does a "name" call first
01:28replacahttp://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/java_utils.clj#68
01:28replacais the source
01:28eeeok, thanks
01:29eeei get it now
01:30eeeso the return value that you see in the repl
01:30replacap
01:30eeeisn't really a string
01:30replaca*np
01:30eeeeven though you see it
01:30replacafor a sym, that's right
01:30eeebut if you want it in a program as a string you do that
01:31replacathe repl will always show you strings in ""
01:31replaca,"hello"
01:31clojurebot"hello"
01:31replaca,'hello
01:31clojurebothello
01:31eeeok
01:31replacabut I get tripped up by that all the tiime when I'm not paying attention
01:31eeenumbers then are a lottle more confusing.
01:32eee,3
01:32clojurebot3
01:32eee,'3
01:32clojurebot3
01:32eeewhat's the difference there?
01:32eee3 the sybol and 3 the number, right?
01:33replaca,(class '3)
01:33clojurebotjava.lang.Integer
01:33replacanope, both numbers
01:33replaca' doesn't make it a symbol, just quotes it
01:34replaca,'"hello"
01:34clojurebot"hello"
01:34eeei thought without the quote it was a symbol
01:34eeeeither way
01:34replaca,(class 3)
01:34clojurebotjava.lang.Integer
01:34eeeone just doesn't try to expand
01:34replaca,(+ 3 3)
01:34clojurebot6
01:34replacawouldn't work to well with symbols
01:34replaca*too
01:34eee,(+ '3 '3)
01:34clojurebot6
01:35eeeok
01:35eeeis there an "is symbol" pred?
01:35replaca,(symbol? 'hello)
01:35clojurebottrue
01:36eeeduh
01:36replacayou could've guessed that!
01:36eeetoo easy
01:36replaca:-)
01:36replacanice thing about clojure, not too cryptic
01:36eeeuhhh
01:36eeeif iyou are used to it
01:36eeelots of conventions
01:36eeelike
01:37eee"with-
01:37eeei have no idea what all that with stuff is
01:37replacayeah, best to spend time rereading doc on clojure.org and absorbing ideas
01:37replaca(and then reasorbing them)
01:37replacaand also reading everyone's code
01:37eeesomeone had a really really long article
01:37eeei can't remember where
01:38replacauh, yeah?
01:39eeelooking now
01:39eeehttp://jnb.ociweb.com/jnb/jnbMar2009.html
01:39kotarakmark volkmann prbably
01:39kotarakright
01:40eeeyup
01:40eeei been too lazy to read it
01:40eeewill check it out now
01:41replacaeee: I can't remember, are you a Java guy?
01:41eeei doubt it will cover the "with" convention
01:42eeewell I can cay I know more java than lisp
01:42replacaprobably not. Some things are just learned by reading lots of code
01:42eeeand I used to be into c++
01:42kotarakwith convention?
01:42replacathat looks like a good intro (on a quick skim) for someone familiar w/Java and similar languages
01:43eee"with" convention
01:43replacayeah, you'll see the with convention used lots of times
01:43eeeusing "with" in front of stuff
01:43replacait's nice once you get used to it
01:43eeewhat's it mean?
01:43replacawell, with is usually a block indicator
01:43replaca,(doc with-open)
01:43clojurebot"([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."
01:44kotarakIt 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.
01:44replacait's like a way of capturing a particular try/finally combo
01:44eeeoh ok
01:44kotarakEg. 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.
01:45kotarakexactly. Same example. :)
01:45eeeseems like a lame name for describing that
01:45eeei would have never guessed
01:45replacawell, when you know the convention, it makes sense
01:45kotarakSimilar: with-out-str, with-in-str ....
01:45eeeyeah, I can't guess at those by their names at all
01:45eeemakes it hard to look at examples
01:46eeemust be a lisp convention
01:46replacaand it makes sense for the convention cause it's always "do the following, with "this" being true for some "this"
01:46kotarakeee: you can't accomodate to all users.
01:46eeeok
01:46replacanot so high-falutin', visual basic and some other have also used it :-)
01:47replacathough not quite as generally
01:47eee,(doc with-out-str)
01:47clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
01:47eeei kinda see
01:48eeei read that as "str-on-out"
01:48replacathat one's nice cause it encapsulates the binding + digging the string out of the string writer which is pretty ugly
01:48eeeas in apply str to out
01:49replacathough I'd use (cl-format nil ...) but I'm weird (& biased)
01:49eeeso you could implement slurp using with-in-str
01:50replacano, that's not right
01:51replacathe str in this case is the input
01:51replacaso instead of reading from *in* it reads from the string
01:51eeeoh
01:51eee,(doc with-in-str)
01:51clojurebot"([s & body]); Evaluates body in a context in which *in* is bound to a fresh StringReader initialized with the string s."
01:51eeei see
01:51replacalike it says
01:52eeei don't like reading docs :)
01:52eeea function name can be docs, too
01:52replacaIt's hard to get good at languages without reading docs and code
01:52eeei am one of those annoying people that fight about the wording of interfaces
01:52replacayeah, but that's a trade-off especially at the core
01:53eeei am sure it's a convention
01:53replacathe more long names you have the more that's clogging up your visual space
01:53eeejust not necessarily English
01:53replacaand the less it simply becomes a semantic primitive
01:54eeeit works for english by building up
01:54replacagood for beginners, but not so good as you get further into it
01:54eeebut I guess that's what's happening here, too
01:54kotarakeee: 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.
01:55replacathis is why it's great to have a BDFL
01:55eeewhat happened wit hthe ns thread
01:55kotarakEspecially when the BDFL is such a smart guy. :)
01:55replacadoesn't matter how much we argue, he'll make up his own mind
01:55kotarakeee: useless discussion about defns vs. defnamespace vs. ns vs. make-ns ...
01:56eeedon't know that ai never knew that expression b4
01:56replacayup - I was originally atracted to clojure by the good taste I could see in his decisions when I watched the clojure for lispers video
01:56eeethat sounds worthwhile to me
01:56replacaI haven't been disappointed
01:56eeelike I think the ns should have departed from java and been slant-separated and then dot sep, vice other way around.
01:57eeei just missed a lot
01:57eeeof the discussions while clj was being solidified
01:57replacaeee: open editor, start developing language, then you can make all the rules :-)
01:57eeeshould have been clojure-contrib/java-utils.as_str
01:58eeeat any rate, i'm happy this is here
01:58eeeand when I understand it, I'll help explain to others
01:58eeebut
01:58replacawow, that's one I *really* can't get worked up about
01:58eeethey will have similar questions
01:58eeeso good to have good answers
01:59replacayup, Rich almost always hs a really good, thought out answer for what he's doing
01:59replaca(kind of like Guido, but with a different mindset and therefore different results)
02:00eeewell, 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
02:01eeenow that's clear!
02:01eeeor even double colon like c++ :)]
02:01eeeanyway, my fault
02:01eeecause I don't read enough
02:01eeei admit
02:02eeeso lemme try to check out this little book
02:02replacayup, gotta read when you come to a new lang, esp. when it's different than the others you've worked with
02:02replacabut do it in little chunks and write in between
02:03eeei didn't know scala was considered functional
02:04eeethe real problem is branching
02:04eeehe had a link to scala and now I'm interested in checking that out for a few minutes :)
02:05eeenice chattin. i'm off to read for a bit
02:05replacai 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
02:05eeethanks for the info
02:05replacahave fun
02:05replacanp
02:05eeei also want to learn J
02:44kotarakreplaca: is it planned to do two times auto-doc for rev 731?
03:04replacakotarak: whenever you see that it means I'm adding features to the autodoc (or trying to work around stupid google wiki bugs)
03:05kotarakreplaca: Ok. Just wanted to make sure you are aware of it. Looked a bit ominous: two times the same revision...
03:05replacayup, it often happens
03:05replacathere will be lots of changes the next couple of days as I add doc
04:28primus99_hello
04:34paddyJhello all
05:05Lau_of_DKHi guys
05:05kotarakHi Lau
05:05Lau_of_DKOla mon Kota :)
05:06p_llol. I read that as "Ola has a Cat"
05:12kotarakp_l: hehe, kotarak means tomcat
05:12fyuryup_l: are you from PL? ;-)
05:13kotarakOr Czech?
05:14Lau_of_DKfyuryu: Im from DK :)
05:15kotarakLau_*of_DK*: really? wouldn't have thought of that! ;)
05:15Lau_of_DKHmm :)
05:16fyuryuLau_of_DK: I'm not Danish but I'm in DK right now
05:16Lau_of_DKWhere are you from ?
05:16fyuryuLau_of_DK: Poland
05:16Lau_of_DKAh ok - Well, welcome to our little tribal community :)
05:17fyuryuLau_of_DK: by "tribal commubuty" you mean Denmark or this channel?
05:19Lau_of_DKI mean Denmark
05:19Lau_of_DKSomebody 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
05:19fyuryuLau_of_DK: heh, thanks. I would't call it tribal, though
05:19Lau_of_DKThats because youre not part of it :)
05:24leafwkotarak: 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?
05:24kotarakleafw: just ant, without install
05:25leafwkotarak: thanks.
05:30leafwkotarak: java.lang.ExceptionInInitializerError
05:30leafwhum, which version of clojure-contrib does vimclojure need? I have latest from repos.
05:31leafwI think it's clojure.jar that is broken actually
05:38kotarakleafw: look down the stack trace. There is a line "Caused by..." there is more useful information on what happens.
05:40leafwI've rolled back the clojure repos a bit, and now I get : java.lang.ClassNotFoundException: clojure.contrib.pprint.PrettyWriter (pprint.clj:23)
05:41kotarakleafw: you must compile clojure-contrib: ant -Dclojure.jar=... in the contrib directory!
05:41leafwit's somehow expecting the clojure-contrib.jar to be built with AOT
05:41leafwaha, so that was it :) trying ...
05:42kotarakTom Faulhabers pretty printer needs AOT...
05:42leafwit's cokmpiling now.
05:43leafwI couldn't understand why the slim.jar had the same size
05:43leafwnow it grew to 1.7 m
05:43leafwok worked
05:43leafwwhat a detour
05:43leafwthanks kotarak
05:48leafwso 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
05:48leafwmy ,vimrc has not changed since 2.0.0
05:49kotarakleafw: what does ":echo b:vimclojure_namespace" say?
05:49leafwE121: Undefined variable: b:vimclojure_namespace
05:49leafwso that is new to me
05:50kotarakYes. It's not started.
05:50leafwmy nailgun is running
05:50kotarakIs the ng client in a different dir now? (maybe before something-2.0.0 and now something-2.1.0)?
05:51leafwbefore, I copied all contents from ~/.vim/plugin/ to ~/.vim/ to make it work. Perhaps my vim setup is not right
05:52kotarakplugin? There shouldn't be a single file in ~/.vim/plugin
05:52kotarakThe directory layout should as in the source directory.
05:52leafwyou mean under .vim/ ?
05:52leafwant install puts all under ~/.vim/plugin/
05:52leafwnot under ~/.vim/
05:53kotarakWhat did you set the vimdir in local.properties?
05:53leafwkotarak: you are right. I did write plugin in there.
05:54kotarakAargh. Another stupid doc phrasing. I should remove the trailing plugin in the README.txt. It is not meant to mean ~/.vim/plugin....
05:54kotarakThis might cause confusion.
05:56leafwkotarak: it's not easy to write fool-proof docs.
05:57leafwkotarak: my defense ialsways to write examples. Like, "for *nix systems, use this local.properties file ..."
05:57Lau_of_DKAnybody worked out how to fetch the jetty session-id from compojure?
05:57kotarakleafw: 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...
05:58leafwit'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)
05:59kotarakleafw: 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"....
05:59kotarak-.-
05:59leafwxD
05:59kotarakleafw: did you watch the screencast?
05:59leafw"where is the 'any' key?"
05:59leafwI don't know of any screencast
05:59kotarakhehe
05:59kotarakhttp://kotka.blip.tv
06:00leafwthanks
06:00kotarak"Press any key" -> Shift, hmmm, Shift, Shift, Shift "Hey! It doesn't work!"
06:00leafwxDD
06:00leafw"Press any non-modifier key" wouldn't work either
06:19kotarakBoah. This google groups pages things is sooo idiotic.... Google is hyped too much...
06:23leafwkotarak: has the local leaderchanged by the way? '\' doesn't work anymore ... got onlysyntax highlighting
06:24leafwand :he vimclojure doesn't work
06:24leafwone feels helpless: the vimclojure-2.1.0 doesn't explain any of this really
06:24leafwshort of reading the doc/clojure.txt
06:54Lau_of_DKDoes anyone here know, why JSessionID isnt the same all over the site (ie. sometimes it null, nottimes its not) ?
07:37MikeSethwhy cant you all just use RCS
07:37MikeSetherr, wrong window
07:39Chousuke:)
07:39ChousukeNot every one of us is a masochist.
08:12AWizzArdDoes (count my-list) always return in constant time when my-list is an instance of clojure.lang.PersistentList?
08:24hiredman,(counted? '(1 2 3))
08:24clojurebottrue
08:25hiredmanI guess so
08:25hiredman,(doc counted?)
08:25clojurebot"([coll]); Returns true if coll implements count in constant time"
08:25hiredman,(class '(1 2 3))
08:25clojurebotclojure.lang.PersistentList
08:26AWizzArdSo there is probably a private slot in the Java code that keeps track of the number of elements.
08:27hiredman~def c.l.PersistentList
09:21leafwanybody on vimclojure : how come 2.0.0 respects the localleader \ mapping but 2.1.0 doesn't react to it?
09:34leafw:echo maplocalleader claims the var is not defined.
09:41kotarakleafw: 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 \.
09:41kotarakYou can check the bindings with :nmap without arguments.
09:43leafwkotarak: thanks. Something fishy is oging on
09:45leafwkotarak: so no leaders are defined. Yet, whjen I push \et, the 'e' gets executed to go to end of workd.
09:45kotarakIt 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.
09:47leafwdoesn't work either. This is default vim frlo ubuntu with a .vimrc that I have not changed since vimclojure 2.0.0
09:47kotarakleafw: what does ":set filetype?" (<- with ?) say in a clojure file?
09:48leafwfiletype=clojure
09:48kotarakDoes the nailgun-client variable point to the right place?
09:48leafwaha
09:49leafwnot set
09:50kotarakSo is the client in your PATH then?
09:51leafwon min
09:51leafwone min
09:54leafwtis is beyond me kotarak
09:54leafwnot enough docs
09:55leafw"the vimclojure#NailgunClient variable"
09:55leafwwhat's that?
09:55kotarakJust a sec. Execute the following from within Vim: ":! ng de.kotka.vimclojure.nails.NamespaceOfFile < %"
09:55clojurebotvimclojure is state-of-the-art
09:56leafwit's not a "let g:NailgunClient=...." by any chance?
09:56kotarakWhat does is say?
09:56kotarakleafw: "let vimclojure#NailgunClient = '/path/to/your/ng'"
09:56leafwgreat
09:56leafwthat would have helped a lot in the docs :)
09:57kotarakleafw: this is almost verbatim from the README.txt...
09:57leafwindeed: between ----8<---
09:57kotarakYep.
09:58kotarak"Please cut here."
09:58leafwmy attention span is short. Sorry. I am a dev too; I know how silly our users seem.
09:58kotarakShould I use indentation for the examples?
09:58leafwwhat would help IMO is a full vimrc-example file, for instance.
09:59kotarakOk. Just working on a FAQ with example.
09:59leafwtalking 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.
09:59leafwand 2.0.0 didn't need this nailgun variable, IIRC
09:59leafwthat confused me.
10:00kotarak2.0.0 also had this.
10:00leafwthen, I don't understand how I ever got it to work :)
10:00kotarakIf you didn't need it there, ng should be in your PATH env var.
10:00kotarakWhat did the ! command above say?
10:00leafwI launch my ng from a shell, with a java -cp .... command.
10:00leafwthe ! command said "nothing to see here", not defined
10:01leafwbasically: /bin/bash: -c: line 0: unexpected EOF while looking for matching `"
10:01kotarak? There is something very fishy there...
10:02kotarakWhen execute the command (w/o : and ! and a file instead of %) in the shell. What does it say?
10:02leafwthe command translates % to the name of my file
10:02leafwto: :! ng de.kotka.vimclojure.nails.NamespaceOfFile < test_levelsets.clj
10:03kotarakYes. But the % of course only works in Vim.
10:04leafwwhat is not resolved yet here is the ng variable
10:04leafwI 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:04leafwnot via ng
10:05kotarakTry the following: ":let vimclojure#NailgunClient = '/Users/leafw/Clojure/VimClojure/ng'" and then edit a clojure file. Does it work then?
10:05kotarakThis ng is the client. What you mean the server. The server is started outside of Vim with whatever setup you want.
10:05leafwtht assumes ng knows how to find the jars I need
10:05leafwthat's what I am trying t ofigue out now
10:06kotarakThe client just contacts the server and plays proxy.
10:06leafwah!
10:06leafwgreat
10:06leafwsee, my assumptions get in th eway
10:07leafwok now ng is working, because it already complains about my misue of clojure namespaces :)
10:07leafwthanks for all the help kotarak. I appreciate your patience very uhc.
10:07kotarakOk. Np. :)
10:07kotarakI'll try to get the docs clarified.
10:08leafwalso, it' a bit weird that thr nailgun server expects the clj files on the classpath: it should add them as one edits them.
10:08leafwi.e now I have to add my working dir to the classpath
10:08leafwand when failing, one doesn't even get syntax highlighting
10:12kotarakVimClojure 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:21leafwkotarak: 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:21leafwbut never mind, I am sure you went through enouhg :)
10:22leafwinstead, I will add a bash script to my nailgun init file
10:22leafwto searh for all folders with clojure files in them
10:22leafwand add the parents as defined in the headers of such files.
10:23kotarakleafw: http://kotka.de/projects/clojure/vimclojure.html Scroll down to FAQ. What that have helped?
10:24leafwnice. Another box in between showing how to launch the nailgun server (i.e. instantiate java JVM etc) would alos help.
10:24leafwthat is the easy part for me, but harder for non-java devs.
10:27kotarakleafw: Like that?
10:27leafwkotarak: you are minimalist!
10:27kotarakI am?
10:28leafwI 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:28leafwnevermind
10:28leafwI guess it's reasonable to assume that someone wanting to use clojure should know something about java classpath.
10:28leafwand use -classpath instead of -cp, so it makes sense to a first-time reader.
10:29kotarakWell. 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:29leafwup to know, I found it quite high. This FAQ should help.
10:32kotarakThat's where the impressions differ. Heck, I even did a screencast with the whole install session.... :|
10:33leafwkotarak: 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:33leafws/short/slow/
10:37lepassiveHi is enclojure fixed for Netbeans 6.7 yet?
10:38kotarakWell. 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:39leafwkotarak: 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:48Lau_of_DKkotarak: I have a solution to all your problems :)
10:49kotarakLau_of_DK: let me guess it start with S and is all capitals?
10:49Lau_of_DKThats right :P
10:50kotarakhehe Can SLIME complete static class members?
10:50AWizzArdno
10:50Lau_of_DKNot to my knowledge - But Im confident its a small extension
10:51AWizzArdLau, do you have a slime right now before you?
10:51kotarakLau_of_DK: does SLIME highlight *all* functions and macros differently?
10:51AWizzArdcan you please type into the repl: 1<Enter> then 2<Enter> then 3<Enter> then *3<Enter> and then *1<Enter>?
10:51Lau_of_DKNo of course not, its a tool for _men_ :)
10:52kotarakhahahaha! :)
10:53kotarakleafw: Ok. Explained the setup and made the examples consistent.
10:54leafwkotarak: thanks! By the way, the second box doesn't wrap around.
10:54kotarakhmm.. Will dig the CSS. Maybe wrapping is turned of for code. I'll check.
10:56Lau_of_DKAWizzArd: *1 = 3
10:56kotarakOeh. How do I tell it to wrap around?
10:56AWizzArdLau_of_DK: but it should be 1
10:56AWizzArdthat is a bug in slime
10:56Lau_of_DK3 is fine
10:57leafwhttp://labnol.blogspot.com/2006/10/html-css-trick-for-displaying-code.html
10:57AWizzArdtry to do the same inside the inferior lisp buffer :)
10:58Lau_of_DK:)
10:58Lau_of_DKDoes this cause any practical problems for you ?
10:58AWizzArdin the inferior buffer it works correctly
10:58leafwkotarak: 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:59leafwbut "0p does paste: somehow, the last register got overwritten by vimclojure indentation in opening a new line.
11:01kotarakHmmm... I see.
11:01kotarakI'll check. Thanks for the link, btw.
11:01Lau_of_DKkotarak: You got around to doing anymore screencasts? Like Mercurials patching system?
11:02leafwsure.
11:02kotarakNo, 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:03Lau_of_DKFair enough
11:03Lau_of_DKMagit is awesome though
11:23Lau_of_DKI forgot - How do I un-intern a symbol in my repl ?
11:25MikeSeth(def foo)
11:26AWizzArd,(doc ns-unmap)
11:26clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
11:26AWizzArdLau, I think you can try ns-unmap
11:29Lau_of_DKThanks
11:31Lau_of_DKPoll : Why dont more people use Compojure?
11:31AWizzArdhow many do you think use it?
11:31AWizzArdAnd: out of how many who want/need to write a web app?
11:33Lau_of_DKI 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:33mikh_mmbrnHi 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:34Lau_of_DKAWizzArd: like this guy, he's hopeless
11:34Lau_of_DK(doc serve-file)
11:34Lau_of_DK-------------------------
11:34Lau_of_DKcompojure.http/serve-file
11:34Lau_of_DK([path] [root path])
11:34clojurebotNo entiendo
11:35Lau_of_DKSpecify a the root-path, which is a folder on your class-path, map that to GET "/static" and use that as a reference
11:35mikh_mmbrnthanks! i'll give it a try)
11:35AWizzArdBtw 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:40mikh_mmbrnprobably another stupid question: If I compile everything with ant,then the classpath is in <path id="project.classpath"> </path> ?
11:41mikh_mmbrnin build.xml
11:41AWizzArdLau_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:54leafwAWizzArd: you can add jars and classes to the classpath on a running JVM
12:02AWizzArdleafw: but also routes and servlets to Compojure?
12:22Lau_of_DKAWizzArd: 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:27AWizzArdLau_of_DK: ok, so I need to check that out a bit later.
12:43benatkinAnyone know of any JavaScript libraries that support and encourage a functional, rather than OO style?
12:45gnuvince_benatkin: jQuery?
12:45benatkingnuvince_: jQuery does, more than other languages, but I'd like support for contexts
12:46benatkiner, most other JavaScript frameworks
13:02Lau_of_DKbenatkin: I'd say ClojureScript is your best bet
13:04benatkinLau_of_DK: interesting
13:05Lau_of_DKVery
13:08benatkinLau_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:09Lau_of_DKClojureScript 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:26rlbIs it possible to ask if an object is an instance of a particular struct-map? i.e. something like (defstruct foo ...) (foo? x)
14:28Chouserunless something like that has been added pretty recently, no.
14:29Chouserif the type of the map (structmap or otherwise) matters, you can store it in the map itself.
14:30rlbRight -- just wondering about structures more generally. Thanks.
14:33Lau_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:33clojurebotalter is always correct
14:34ChousukeLau_of_DK: assoc-in? :/
14:34Lau_of_DKaha! Thanks
14:35rlbIs 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:37rlbi.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:37rlbOf course in many cases, it doesn't matter, but sometimes it does.
14:37ChousukeI think the vector implementation reserves some space for quick expansion though.
14:38ChouserChousuke: really? that doesn't seem right to me.
14:38ChousukeI might very well be wrong :P
14:41ChouserI think a list has a whole PersistentList object per element, while a vector has a bit more data in its root object.
14:41Chouserso 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:42rlbIt'd be nice to have a rough idea when trying to design something that'll be dealing with very large amounts of data.
14:42Chouserit'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:42rlbChouser: certainly.
14:44Chouserif 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:45rlbYou mean a java array, and what's LazilyPersistentVector?
14:45Chouser,(class [1 2 3])
14:45clojurebotclojure.lang.LazilyPersistentVector
14:45rlbAhh.
14:46ChouserAn LPV provides a vector interface, but internally hold the entire contents as a single Java array.
14:46Chouseras soon as you assoc or dissoc or anything, it'll unpack the array into a regular vector trie and return that.
14:47Lau_of_DKWhere can I find a list of the possible arguments to alter, like assoc, dissoc, etc ?
14:47rlbChouser: OK, interesting.
14:48rlbmakes sense.
14:51rlbSo 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:53Lau_of_DK,(assoc-in {:foo {:bar 5 :cec 15}} [:foo :bar] 10)
14:53clojurebot{:foo {:bar 10, :cec 15}}
14:54Lau_of_DKThis 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:54Chousukenothing weird.
14:55kotarak(alter some-ref update-in [:foo :bar] inc)
14:55Chousuke,(let [x (ref {:foo {:bar 10} :bar 5})] (dosync (alter x assoc-in [:foo :bar] 42))) @x) ; or htis
14:55clojurebot{:foo {:bar 42}, :bar 5}
14:56Lau_of_DKupdate-in - also a good one, where do you guys get this stuff? Rich got some secret newsletter going around?
14:56Chousukethere's the api documentation :P
14:56kotarakLau_of_DK: no. Just listening to #clojure and browsing clojure.org/api from time to time.
14:57Lau_of_DKIm glad I have you guys :)
14:57kotarakI like this alter/update-in style of providing a function to act on the value. :)
14:59Chouserrlb: 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:59kotarakWhat kind of key shortcut could I use, when r and R are already used?
14:59kotarakFor "refresh" I mean.
14:59Chousukef5? :P
14:59rlbChouser: OK, thanks.
15:00Chousukeor cmd-r if on a mac
15:00kotarakChousuke: 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:01Chousukewell, it's what firefox and safari do
15:21Lau_of_DKTell me again why we dont have import * ?
15:23kotarakLau_of_DK: because it's for the sloppy guys.
15:27Lau_of_DKI've come across classes, not documented well enough for me to import them without having the *
15:27rlbIs the key order stable when writing a map? (I would guess not.)
15:27rlbI would guess that that's undefined.
15:27kotarakWith array-map it's the order of insertion, IIRC.
15:31unlink1Am I missing some standard library macro which accomplishes this? http://dpaste.com/40596/
15:31unlink1Or is there a more idiomatic way of doing this
15:31kotarakunlink1: a vector with conj?
15:32unlink1The idea is to chain a bunch of function calls.
15:33kotarakYou mean like with ->?
15:34unlink1Yeah, 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:34kotarakThere was a pipe macro discussed on the list. Just a sec
15:36kotarakhttp://tinyurl.com/dljm75
15:37unlink1hmm, I thought | was an obvious name.
15:37kotarakFirst | is a shellism, then it is not a valid symbol name...
15:37unlink1It's not?
15:37kotarakNo, IIRC.
15:38unlink1Why doesn't clojure complain?
15:38dreishIt's allowed right now, but I think there are plans to make it a quoting character for symbols.
15:38unlink1oh..
15:38kotarakIt 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:38unlink1I guess then I'd vote for pipe.
15:39unlink1I'm glad there's at least some discussion on the topic, and I'm not the only one looking for something like this.
15:40kotarakThe authoritative source for what's allowed is http://clojure.org/reader
15:41unlink1oh, ok.
15:42Lau_of_DKGuys, 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:43rlbI 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:44unlink1-> and pipe indicate to me that currying would be a valuable addition to clojure ;)
15:44rlb(actually a "tree" of maps where the non-leaf keys are directory names)
15:45kotarakcurrying cannot handle ->. Then there is partial.
15:45rlbSo you would have (((fs "home") "someone") "somefile")
15:45rlb-> file size
15:45unlink1No, technically not, but I think -> is just a less useful version of currying.
15:46unlink1And partial indeed works, but I find it unwieldily verbose.
15:48kotarakYou can also use #(foo :curried1 :curried2 %)...
15:49unlink1You could, but I often want to curry map and reduce with anonymous functions using #()
15:49clojurebotmap is *LAZY*
15:49kotarakThen use partial.
15:51unlink1I wrote the pipe macro to avoid the verbosity of using partial.
16:03rlbHmm, the debian package doesn't seem to include zippers.
16:09z5hi'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:10Chousukehmmh
16:10z5hmaybe i'm doing things wrong :|
16:10Chousukethat sounds a lot like imperative programming.
16:10durka42you could always abuse the exception mechanism
16:11fffejI'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:11Chousukeyeah.
16:11rlbIs clojure.zip part of the normal distribution?
16:11z5hi'm implementing http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Deterministic_variants_of_the_test
16:11Chousukerlb: yes.
16:11rlbHmm...
16:12danlarkinz5h: sweet!
16:12z5hso i'm looping over values of a from a range, and values of r from another range.
16:13ChouserLau_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:13z5hif that test fails i know it's composite ... otherwise keep going
16:14rlbAhh, I was just invoking it incorrectly.
16:14Chousukehmm
16:14Lau_of_DKChouser, perfekt
16:15Chousukerlb: I think you could probably use for
16:16rlbChousuke: to traverse the tree and generate values?
16:16rlbChousuke: actually, I realized that I need a better idea of what I really want.
16:18rlbi.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:19Chousukesomething 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:19rlbI'm not sure zippers are what I want either, but they're interesting.
16:20Chousukerlb: oops, I meant z5h :p
16:20z5hChousuke: i need to digest that for a minute
16:20Chousukerlb: clojure-contrib has some walk functions for traversing zippers. presumably trees as well :/
16:21Chousukez5h: it's basically a direct translation of the mathematical formula
16:21fffejif 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:21rlbFirst 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:22Chousukez5h: for in clojure is not a loop; it's a seq comprehension (it returns a lazy seq)
16:22rlbOf course you could have special terminals like (((fs "home") "someuser") :info), but I'm not sure that's what I want either.
16:23z5hright, so i'm i'm asking for everything to be true, it'll stop as soon as it finds something false
16:23Chousukeyeah
16:23z5hgotcha. thanks
16:24z5hthat will actually make things a lot cleaner
16:24z5h:)
16:24Chousukeactually better would be "(every? identity ...)" since true? only returns true if the item really is the literal "true"
16:24Chousukeidentity will return true for anything not nil or false
16:25Chouserfffej: probably easiet is to (declare foo), then def unmemoized-foo in terms of foo, then finally store the memoized verion in foo
16:26fffejchouser: thanks, that makes sense. I think I was trying to make something WAY too complicated :)
16:27Chouseryou could try using letfn or something, but I've not tried that yet.
16:27Chousukethat way, you won't be ale to use the unmemoised version though, will you? :/
16:28ChousukeI guess that might not be a problem :)
16:28fffejnot to me (at the moment at least!)
16:29ChousukeI wonder if my for beast primality test actually works. it's too simple :(
17:09chessguyso...i know i'm a clojure/lisp newb, but there's something i don't get about macros
17:09chessguyi'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:10chessguyseems like a disconnect
17:10Chousukerlb: hm, maybe each node could be a map, so you could attach arbitrary info? :/
17:10Chousukechessguy: clojure itself uses macros quite a lot :)
17:11chessguyso it's more like macros _should_ be everywhere, and if they're not, it's because the author doesn't know any better?
17:11Chousukehmmh
17:12chessguynot trying to pick any fights either way
17:12chessguyjust trying to understand
17:12chessguyand i recognize it's a pretty vague question too
17:12Chousukein a way they are everywhere because a large part of the core language is implemented with them
17:13chessguyok, but i'm talking about non-core libraries and apps
17:13Chousukemacros can be used when you need a more convenient syntax for expressing a pattern that often appears in your code.
17:13Chousukefor applications, that may not be very frequent.
17:13Chousukeoften you can get away with just functions.
17:14chessguyhm
17:14Chouserchessguy: that doesn't match the literature I've seen.
17:15Chouseror my experience, what little there is of it.
17:16ChouserI 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:17Chousukechessguy: 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:20Chousukechessguy: like with-open or with-monad or with-connection (from contrib.sql)
17:22Chousukesuch 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:23chessguyinteresting idea
17:25AWizzArdofftopic, but good for Star Trek fans: http://www.youtube.com/watch?v=JGAahDeceHI&amp;fmt=18
17:26Chousukechessguy: 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:27Chousuke~source destructure
17:27chessguyChousuke: sorry, i don't know much about destructuring. how is that related to what we're talking about?
17:27Chousuke^ 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:37Chousukechessguy: (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:38Chousukechessguy: that's the kind of stuff macros are meant for.
17:38chessguyhmm
17:40Chousukethere'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:41Chousukeinterestingly, you can also "call" a macro just like a normal function by doing this:
17:42Chousuke,(#'-> 'foo 'bar)
17:42clojurebot(bar foo)
17:42z5hChousuke, mind taking a look at my code? still acting flakey, and I can't see the problem ... where can i post it?
17:42Chousukelisppaste8: url
17:42lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:43lisppaste8z5h pasted "prime test" at http://paste.lisp.org/display/79609
17:43unlink1Is there a builtin for (nth (iterate rest lst) 3)?
17:44eeeOn 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:44z5hhttp://paste.lisp.org/display/79609
17:44Chousukehm
17:44Chousuke,(iterate rest [1 2 3])
17:44Chousukeclojurebot: :(
17:44clojurebotExecution Timed Out
17:44clojurebotTitim gan �ir� ort.
17:44Chousuke,(take 2 (iterate rest [1 2 3]))
17:44clojurebot([1 2 3] (2 3))
17:44eeecalled "cutGreater(maxOk)" . . . .everything greater will be culled from the heap
17:45Chousukeunlink1: I don't think so
17:46z5hand, of course, the algorithm is taken from http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Deterministic_variants_of_the_test
17:46unlink1cdddr in scheme
17:47eeei'll have to get some clojure examples up soon of some solutions using the heap
17:47eee... thought I'd stop in and report progress
17:47Chousukez5h: isn't that or in looksprime supposed to be and?
17:47z5hwell, if both are not equal it's composite
17:48z5hso if either are true, it might be prime
17:48eeeturns out I need to sign off. sorry for the drive-by. check ya later
17:52Chousukez5h: so how is it flakey?
17:52unlink1Why both fnext and second?
17:53Chousukeunlink1: second is more intuitive
17:53Chousukefnext is probably historical baggage? :P
17:53unlink1Pre-1.0 sounds like a good time to cast that aside.
17:55Chousukez5h: style nitpick: instead of (. Math (log n)), use (Math/log n)
17:56z5hChousuke: it says 3 and 7 are prime, but 5 is not :(
17:56Chousukeoh, indeed
17:56ChousukeI conveniently skipped that one :P
17:59z5hi once spent a week debugging something at work because a university textbook i was using had an error in it's pseudocode
17:59Chousukealso (+ x 1), (- x 1) -> (inc x) and (dec x) respectively. but I can't figure out what your problem is :/
18:32unlink1What's the best way to get the current state of a var pointed to by a symbol named by a string?
18:32unlink1I.e. something like (deref (resolve (symbol s)))) ... or is that as simple as it gets?
18:33AWizzArdyes
18:33AWizzArdIt's good that you need to be explicit about it. But you could wrap this any time into a function if needed.
18:34Chousukeyou can replace deref with @ :)
18:37rlbThe API docs might need a section delimiter of some kind.
18:37rlbi.e. outdent section headers, add some space, etc.
18:40rlbSo 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:40rlbs/resonable/reasonable/
18:40hiredmanI believe so
18:40hiredmanactually
18:40rlbi.e. something like a tree "map"
18:40hiredmanyeah
18:40hiredmanzippers are great for that
18:41rlbThey look interesting -- probably worth learning about regardless. Here goes.
18:41hiredman,(doc clojure.zip/next)
18:41clojurebot"([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:42rlbSo first I may need the tree equivalent of file-seq.
18:42hiredman?
18:42clojurebotqcon slides is http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/RichHickey_PersistentDataStructuresAndManagedReferences.pdf
18:43hiredmanclojurebot: chill out
18:43clojurebotPardon?
18:43AWizzArdhiredman: 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:43hiredmanno
18:43hiredmanit is the old doc look up code
18:43hiredmanonly works on core
18:43AWizzArdic
18:43hiredman(doc next)
18:43clojurebotReturns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil.; arglists ([coll])
18:44hiredman(doc clojure.zip/next)
18:44clojurebotNo entiendo
19:18lisppaste8z5h pasted "fixed prime test" at http://paste.lisp.org/display/79614
19:35z5his there a way of making every?, map, etc run on multiple threads?
19:36danlarkinz5h: there's pmap
19:37z5hthanks
19:41z5hwow. i just parallelized part of my code in 10 seconds. amazing!
19:44cadshello all
19:46cadshey, I've been using maps to represent objects with named properties, and defining functions that deconstruct these maps
19:48replacacads: ok
19:49cadsis there a more idiomatic way to work with objects with properties (in this case I have particles with mass, velocity and position)
19:50cadshehe, I think I should use structs, first of all
19:50rlbWhy does conj require a non-empty rest list?
19:50rlb(Am I just not thinking straight?)
19:50hiredmaneh?
19:51rlb(apply conj '{1 2} '())
19:51hiredman,(conj () 1)
19:51rlbCauses an exception here.
19:51clojurebot(1)
19:51hiredman{} is a hash
19:51hiredmanyou need to conj on a key and a value
19:51rlb(apply conj '{1 2} '({3 4}))
19:51rlbis fine
19:52hiredman,(conj {})
19:52clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$conj
19:52rlbOriginal application was (apply conj `{~x ~y} (map ...))
19:53rlbAnd of course I'd rather not have to check whether or not the seq passed to map is empty first.
19:54hiredman,(apply conj {} (seq '()))
19:54clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$conj
19:54hiredmanI do believe it has to do with how aply works
19:54hiredmanapply treats an empty list as no args
19:55hiredman,(apply + 1 2 '())
19:55clojurebot3
19:55hiredmanempty seq
19:55hiredmanI should say
19:56rlbOK. I'll have to reconsider.
19:56rlbThere's probably a better way to do what I'm trying to do anyway.
19:57hiredman,(into {} (map vector (range 10) (range 10 20)))
19:57clojurebot{0 10, 1 11, 2 12, 3 13, 4 14, 5 15, 6 16, 7 17, 8 18, 9 19}
19:57rlbI'm just trying to build a sorted map.
19:57rlb(from individual pairs)
19:57hiredman,(into (sorted-map 1 1) (map vector (range 10) (range 10 20)))
19:57clojurebot{0 10, 1 11, 2 12, 3 13, 4 14, 5 15, 6 16, 7 17, 8 18, 9 19}
19:58rlbOK, that sounds about right. Thanks
20:00hiredman(class [1 1])
20:00hiredman,(class [1 1])
20:00clojurebotclojure.lang.LazilyPersistentVector
20:00hiredman,(ancestors (class [1 1]))
20:00clojurebot#{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:01rlbOh, wait, does into flatten?
20:01hiredmannope
20:01rlbhmm, must be doing something wrong then.
20:01hiredmanwell, what do you mean by flatten?
20:02rlbI'm trying to maintain a tree of sorted-maps.
20:02rlbs/maintain/build/
20:02hiredmaninto takes a collection and a seq, and poors the seq into the collection
20:02hiredman,(into (sorted-map) '([a b] [c d]))
20:02clojurebot{a b, c d}
20:03hiredmanso if you have map generate a seq of two element vectors, you can easily make a sorted-map
20:04hiredman,(instance? java.util.MapEntry [1 1])
20:04clojurebotjava.lang.ClassNotFoundException: java.util.MapEntry
20:04rhickeyNew example at: http://clojure.org/refs
20:04hiredman,(drop 10 (ancestors (class [1 1])))
20:04clojurebot(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:06hiredman~def c.l.Streamable
20:10ChouserI'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:11AWizzArdmakes sense :)
20:11Chousercurrently these are in a lazy seq, and I'm using things like 'for' and 'split-with'
20:12Chouserthe 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:12ChouserShould I use delays or thunks in a vector instead, such that I can be more explicit?
20:15hiredmanso you are asking if it is ok to depend on lazy seqs and lazy-seq consuming functions being lazy?
20:17rlbhiredman: thanks -- that worked, I just wasn't doing what I thought I was doing.
20:17rlb(took way longer than it should have -- still not used to clojure vs scheme/cl)
20:26lisppaste8rlb pasted "first-pass, trivial fs-tree" at http://paste.lisp.org/display/79616
20:26rhickeyChouser: as long as you can detect the error and stop pulling, you should be able to rely on the fully lazy seqs
20:27rlbhiredman: I imagine that needs work, and could perhapd me more idomatic, but it'll do for the moment.
20:27rlbs/perhapd me/perhaps be/
20:27hiredmanthe what and the which now?
20:28rlbhiredman: I just pasted the thing you were helping with.
20:28hiredmanoh
20:28rlb(fs-tree (new java.io.File "foo")), for example
20:29hiredmanirc client is having rhickey and lisppaste8 the same color
20:29rlbIt just creates a tree of sorted maps representing the java file objects.
20:29hiredmanirc client is having rhickey and lisppaste8 the same color
20:29hiredmanerp
20:30hiredmaninteresting
20:32hiredmanif you are planning to use zippers, I think it would be possible to generate a zipper of a filestem without an intermediate representation
20:33rlbhiredman: interesting -- is that using zipper?
20:33hiredmanyeah
20:33rlbArgh -- didn't pay attention to that.
20:33hiredmanbut I dunno how useful a zipper over a a filesystem would be
20:34rlbhiredman: how would that work? Does it memoize, or would it constantly refer to the fs?
20:34hiredmanfilesystems tend to be mutable and zippers are not
20:34rlbhiredman: in this case it might be fine -- the assumption is that the fs is static.
20:34hiredmanrlb: you provide zipper with the functions it needs to generate a zipper structure
20:35hiredman,(doc clojure.zip/zipper)
20:35clojurebot"([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:35rlbhiredman: right, but is that approach likely to result in a lot of fs references for repeated traversals?
20:35rlbThe other approach won't.
20:35rlb(though that may not be critical)
20:35rlbActually, I might want both...
20:36rlb(fs-map sometimes, and a (zipper...) based result other times)
20:36Chouserrhickey: ok, thanks.
20:36hiredmanthe zipper functions are not called when you tranverse the tree
20:37hiredmanthe zipper functions are used to generate a zipper data structure on top of the tree, which is traversed by the various utility functions
20:38hiredman,(-> '(a (b c) d) clojure.zip/seq-zip)
20:38clojurebot[(a (b c) d) nil]
20:38hiredman,(-> '(a (b c) d) clojure.zip/seq-zip next)
20:38clojurebot(nil)
20:38hiredman,(-> '(a (b c) d) clojure.zip/seq-zip clojure.zip/next)
20:38clojurebot[a {:l [], :pnodes [(a (b c) d)], :ppath nil, :r ((b c) d)}]
20:40rlbFWIW 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:40rlbOf course, I'm not sure how that'll translate to clojure's in-RAM use.
20:41rlbTo some extent, I'm just using this as an excuse to learn more about clojure.
20:41hiredmanhmm
20:43rlbImagine 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:44hiredman,(-> `(1 ~(iterate inc 0) 2 3 4) clojure.zip/seq-zip clojure.zip/next clojure.zip/node)
20:44clojurebot1
20:44hiredmanI guess zippers can be lazy
20:45rlbAnyway, 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:46hiredman,(-> `(1 ~(iterate inc 0) 2 3 4) clojure.zip/seq-zip clojure.zip/next clojure.zip/next clojure.zip/next clojure.zip/node)
20:46clojurebot0
20:49rlbWhen I get time, I'd still like to look in to the possibility of #!/usr/bin/clojure support.
20:58hiredmanrlb: everyone seems to have rolled their own scripts for launching clojure and for shebang support
20:58rlbhiredman: oh, well, then I suppose I don't need to do it too, but it'd be nice if there was standard support.
20:59rlbDebian has a /usr/bin/clojure, but it's not what I'd want.
21:08rlbIs (dorun (map f x)) the apropriate substitute for something like for-each?
21:10hiredmandoseq is more foreach like
21:11hiredman,(doseq [i (range 10)] (print i))
21:11clojurebot0123456789
21:12rlbhiredman: so you'd have something like (doseq [x items] (f x))?
21:13rlbI 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:13rlb(want to know if I'm wasting my time)
21:14hiredmanwell, the main thing is maps are not lazy and you are making a map, so everything is getting loaded
21:15rlbhiredman: right, but not in the current test.
21:15rlbChanged it to just (prn (.getName file)) and use dorun for the sub-dir map.
21:18rlbSo 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:19rlbPerhaps 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:21kadaverhttp://groups.google.com/group/clojure/browse_thread/thread/c0819f314391a311#
21:21kadavernoone has any comments on general style of that mp3player?
21:22kadaverim really wondering if it can be done in a cleaner more clojure-ish way
21:22kadaverbecause i feel like i would have been better of writing it in C even...
21:23cadswhere can I find a tutorial that shows me how to overload the + operator so that it works different for different types of arguments?
21:24kadavercan you eval things here with clojurebot?
21:24kadavercads: not sure if you can overload + but the normal way s to use multimethods
21:24cadslike 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:28kadaverdo you really do that often enough to bother ?
21:28kadaver(defmulti + ...
21:29kadaverbut im not sure f you can us emultimethods in buitins...try it and see
21:31rzezeskiQ 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:32rzezeskiand without using viper/vimpulse mode
21:36cadskadaver, I find symbolic operators are a strong mnemonic for me
21:38cadslots of times we can define cool structures with a few custom operators and some named functions defined mainly in terms of those operators
21:44kadaveruser=> (defmulti + (fn [x y] (class x)))
21:44kadaverjava.lang.Exception: Name conflict, can't def + because namespace: user refers to:#'clojure.core/+ (NO_SOURCE_FILE:1)
21:44kadaveri was afraid of that
21:44kadaverso not sure if you can
21:44kadaveruser=> (defmulti ++ (fn [x y] (class x)))
21:44kadaver#'user/++
21:44kadaverperhaps?
21:45kadaverwhere is set/union?
21:49cadsI think that would work
21:53kadaverthen you use defmethod to declare what shoud happen
21:58DMisener/help
21:59DMisener!help
22:01kadaverHELP!
22:02rhickey_,(doc clojure.set/union)
22:02clojurebot"([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets"
22:02barkleyjust wanted to tell stuart that i bought the book because the mobi format
22:03barkleyreading clojure on the kindle rocks
22:04barkleyanybody doing any video processing with clojure?
22:05barkleyI guess the real question is how to do video processing without being tied to windows COM libs
22:08kadaverhttp://hpaste.org/fastcgi/hpaste.fcgi/view?id=4543#a4543
22:08kadaver^^ whats wrong with that? i didnt use mutimethods a for a long time, dont remember hwat im doign wrong
22:15dliebkekadaver, try this: (defmethod ++ clojure.lang.PersistentHashSet [a b] (clojure.set/union a b))
22:16kadaverits for cads anyway
22:17kadaverhttp://hpaste.org/fastcgi/hpaste.fcgi/view?id=4544#a4544
22:17kadaver^^ cads, mutimethod and example
22:17kadaverhttp://clojure.org/multimethods
22:18cadshey, 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:18cadsbut I don't know if it'll return a vector or a set or a list
22:19kadaverhow do you dispatch on 2 values?
22:20cadsmost functions are implemented as maps
22:20kadavervec
22:20kadaverhow do you eval here?
22:21kadaverclojurebot: eval?
22:21clojureboteval is evil
22:21kadaverclojurebot: eval
22:21clojureboteval is DENIED
22:21cads,(vec '(1 2 3))
22:21clojurebot[1 2 3]
22:21cads,(vec #{1 2 3})
22:21clojurebot[1 2 3]
22:21cads,(vec {1 2 2 3})
22:21kadaver,(vec {1 2 3 4})
22:21clojurebot[[1 2] [2 3]]
22:21clojurebot[[1 2] [3 4]]
22:22cadsso I'd just want to write all my functions and make sure they call vec on the answer they create
22:22barkleyi'm not much of a programmer, but isn't everything really event-based?
22:23hiredmannope
22:23barkleyhiredman: in modern programming, we do database, web servers, guis....why isn't everything event-based?
22:23clojurebotwhy not?
22:23barkleyoops. wrong nope?
22:23hiredmannot everything is a gui
22:23barkleydidn't say that
22:24hiredmanI didn't say you did
22:25hiredmanbatch programming (non-interactive processing jobs) generally don't make sense as events
22:25hiredmanfor example
22:26cads,(take 10 (vec (repeatedly inc 0)))
22:26clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$repeatedly
22:26barkleytrue, and how much "batch" programming are we doing thes days...as in, "let's run this payroll program at 3am"
22:26cads,(take 10 (vec (repeatedly rand)))
22:26clojurebotjava.lang.OutOfMemoryError: Java heap space
22:26hiredmancads: vec is not lazy
22:26hiredmanbarkley: a lot
22:26cadsjust found that out :)
22:26barkleyhiredman: not really
22:27barkleyhiredman: but even in the case of batch programming, they're still events involved
22:27hiredmanbarkley: for example MapReduce/hadoop stuff
22:27cadsis there a function that takes a sequence and returns either a persistent vector or a lazily persistent vector?
22:27barkleyhiredman: well, i guess i disagree with you...we'll leave it at that
22:28hiredman,(class [])
22:28clojurebotclojure.lang.PersistentVector
22:29kadavercads: doesnt most vectorn functions retuen a double or int anyway?
22:29hiredman...
22:29cadskadaver, are you a little tipsy over there?
22:29kadaver,(take 10 (vec (repeatedly #(inc 0))))
22:29clojurebotjava.lang.OutOfMemoryError: Java heap space
22:29kadavertipsy?
22:30barkleywe're programmers, we're always tipsy;)
22:30cadsbarkley, events are cool, but they're not that great of a model of computation and concurrency, I don't think
22:30barkleycads: hmm...i just see it as higher-level fundamental though
22:31barkleycads: isn't a post/get an event?
22:31cadsplus, there are many different frameworks for that
22:31kadaver, (vec 1)
22:31clojurebotjava.lang.Exception: Unable to convert: class java.lang.Integer to Object[]
22:31barkleycads: granted i'm not a http programmer guru
22:31cadsconsider the philosophies of communicating serial processes, or the Pi calculus
22:31barkleycads: that's my point
22:32kadaver, (defn pure [x] [x]) (pure 10)
22:32clojurebotDENIED
22:32barkleycads: you know anything about dataflow?
22:32kadaver, (let [pure x [x]] (pure 10))
22:32clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
22:32barkleyhere's my deal..i've never felt comfortable with OO programming...too much state...too much spaghetti internals in objects
22:33barkleyOO "gurus" tell us static methods are bad? why?
22:33cadswell you're here safe in a more functional world
22:34cadsfor event type stuff, there are agents
22:34barkleycads: just bought the book, i'll definitetly get to that. thanks!
22:34cadsyeah, agents can easily be used for event based modelling
22:35barkleycads: 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:35barkleyi think i'm brain-damaged by OO
22:35barkleywell, maybe not....i never bought into it in the first place
22:36kadavercojurebot: OO?
22:36kadaverclojurebot: OO?
22:36clojurebotOO is to programming what astrology is to astronomy
22:36cadsheh, 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:37kadavercads: where do you study?
22:37barkleyi don't compare event and state
22:37barkleyevent seems fundamental, state seems very hackish for most purposes
22:38cadsevent and mutable state go hand in hand
22:38barkleyi'm sorry cad...i was talking dataflow
22:38barkleyyou guys ever studied dataflow languages?
22:38barkleycads: not sure what you mean
22:39barkleywhy does an event have to be with mutable state?
22:39barkleyi guess i'm getting at dataflow
22:39barkleymore of a real engineering perspective
22:39cadsobjects only ever flag events when their internal state reaches a certain point
22:40barkleybut that's irrelevant to functional languages or state
22:40barkleyor maybe i'm missing something
22:40barkleyat our fundamental level, we have callbacks
22:40barkleywe register a callback and it happens
22:41barkleysorry if i'm a loser on this
22:41barkleyi just always question things...like OO
22:41hiredmanif you think callbacks are fundamental I recommend you search the ia32 isa for a register callback instruction
22:42cadswouldn't dataflow language make it harder to deal with a bunch of state mutating and changing which way the data has to flow?
22:42barkleycads: isn't that the point of functional languages?
22:43barkleycads: dude, i'm not expert, i'm just trying to figure things out
22:43cadsthose prefer to deal with streams of data and to have little changing state
22:43barkleywe have state change
22:43barkleylet's not try to blow that off
22:44cadsbarkley, I was wondering if you were coming from a dataflow language background
22:44barkleyno, no
22:44barkleyi thought you might know something:)
22:44barkleyisn't an exception a higher-order event?
22:45cadslol, I don't think I'll like exceptions till I read a paper that shows me how to write a formula for them
22:45cadsI don't think exceptions belong in my programs
22:46barkleythat's why we need Some-Nothing?
22:46barkleyas in many other fucntional languages?
22:46cadsoh, have you followed the bottom discussion?
22:46barkleyno
22:46barkleyi'm new
22:47cadsI wouldn't be against a bottom type
22:47barkleyit's insanse that in C# 3.0 extensions that i get caught in godamn chain with a null
22:48barkleynulls should be dealt with gracefully
22:48barkleyi guess..like i said i'm not much of a programmer
22:48cadshehe, your questions are all over the place
22:49cadsyou just need to focus and study
22:49barkleyall i know is that OO kindof sucks
22:50barkleyfor the time being i'll use clojure for mysql database munging
22:50cadslook at this site, so far I like it better than stuart halloway's actual book, athough the book is more conversational
22:50cadshttp://java.ociweb.com/mark/clojure/article.html#References
22:50barkleycads: been there...have it open
22:50barkley...open in tab
22:50barkleyi bought stuart's book last night because it's on mobi format
22:50barkleyso i can read it on my kindle
22:50cadsisn't the site great?
22:50barkleyStuart!...i bought because of kindle!
22:51barkleymark lives in st. louis with me
22:51cadsI want one of those damn things so bad
22:51barkleynever met him..but i reallly appreciate that great intro
22:51barkleyexpensive as hell
22:51barkleyrelative
22:51barkleymom gave it to me for christmas
22:52barkleythe only thing that sucks is that pdf conversion bites for programming type texts
22:52barkleyand kindle2 doesn't resolve that
22:52cadsanyways, 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:53barkleycads: dude, the reason i come to clojure is because of sequence unification and REPL
22:53cadsit's good stuff
22:53barkleycads: the concurrency will come later
22:53barkleyhow can you develop without a REPL?
22:54barkleyit's insanse...
22:54barkleyi do little console projects in C# 3.0
22:54cadsyeah, other languages are painful now
22:54barkleyand OO screws it all up anyway
22:55cadsOO is okay, for happy joyous and light OO, check out ruby or smalltalk
22:55barkleyi'm just happy that enclojure rocks because i despise emacs....love VIM....haven't checked out Gorilla
22:55barkleyi don't think OO
22:55barkleyi think in data
22:55barkleyand how i can TRANFORM it
22:56barkleythat's the whole point of programming
22:56barkleynot this boiler-plater....messaging...gobbly-gook
22:56cadswere you wondering about higher order functions earlier?
22:56barkleyno, i know i can simulate anything i want with closures
22:56barkleymaps..whatever
22:56barkleyOO-wise
22:56barkleyhere's my deal
22:57barkley...
22:57barkleyand actually my philosophy
22:57barkleyOO is total premature-optimization
22:57barkleyyou scaffold this shit, and then you tear it down...AKA refactoring in the OO world
22:58barkleyanother rant on OO....the world is NOT OO
22:58barkleythe world is data and functions that work on data
22:59barkleysorry for the rant
22:59cadslol
23:00barkleywhen i saw rich say "I'm trying to get away from OO"...I knew i had to check it out
23:00cadsyeah, we don't really talk too much about 'OO' here, you seem to have a real chip on your shoulder about it
23:01cadsjust chill out, relax, enjoy the anonymous and generic functions :)
23:01barkleycads: 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:01benatkinI don't hear erlang people bash OO, and so far I haven't heard any clojure people bash it either.
23:01barkley"where does this damn method belong"?
23:02barkleybenatkin: i'm bashing OO
23:02barkleybenatkin: all i know is what i see
23:02barkleybenatkin: and i didn't bash Erlang
23:02cadsbenatkin: I'll bash java and c++ oo, but pure I have some respect for pure OO theory
23:02barkleybut...we have multi-methods!
23:02barkleyso we don't need this retarded tree
23:02benatkinyeah...that's what I've seen with erlang
23:03barkleythe world is not a tree
23:03benatkinsomeone did an artilce "Why erlang isn't especially OO"
23:03barkleybenatkin: saw it
23:03benatkinI thought that was a nice take on the issue
23:03barkleyactually..
23:03cadsbarkley, we'd be upset at OO if they could do something we couldn't do
23:03barkleyPaul Graham did "why arc isn't especially OO"
23:03cadsbut we can do a great deal they can't, easily
23:03barkleyor not at all
23:04benatkinI used to bash OO, but that distracted me, big time
23:04barkleyi want OO when i need OO damnit!
23:04barkleyif i don't need it, then don't force it fucking on me!
23:04benatkinso I don't do that any more. I just try to learn about it and pick and choose what OO techniques I like
23:04cadsif you're bashing OO that means your brain's still thinking in terms of objects, and hating it :D
23:04barkleycads: no brother, i never drank the kool-aid
23:05barkleycads: so i'm at home in clojure:
23:05barkleyand i'll be hiring someone soon
23:05barkleyi don't want anybody that can't handle lisp
23:06cadshey barkley, does enclojure provide namespace completion in its code completion feature?
23:06barkleycads: completion is a bit flakey
23:06clojurebot1
23:06barkleyi need to contribute
23:06barkleyi'm used to VS completion though
23:06barkleywhich i love
23:06verec_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:07barkleyand java IDEs don't do off the shelf, which is "i know what your trying for and i'll pop up"
23:07rzezeskibarkley, I hate to break the news to you, but Clojure was bootstrapped in Java :) OO strikes again!
23:07barkleyverec_: it's the case of i want to dispatch on what i want to dispatch on
23:08verec_sure. Example?
23:08barkleyverec_: no, not off the top of my head, i'm doing a c# 3.0 chromakey app right now....sorry
23:08barkleyi want to dispatch on what i want to dispatch on though?
23:09barkleymore dynamic typing than anything
23:09barkleyi reverse engineer classes based off a mysql database
23:09cadsverec, I dunno, I used OO in a environment where it was pretty friendly, and miss some of the encapsulation features from there sometimes
23:10barkleyhere's the problem
23:10verec_cads, can you be more explicit, please?
23:10barkleyeverytime 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:11barkleyverec_: bottom line is that i don't think OO
23:11barkleyNice had predicate-dispatch which was "nice"
23:11barkleypoor "nice"
23:12barkleylove predicate-dispatch
23:12verec_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:12barkleyverec_: i don't wan to be contrained by a tree hierarchy
23:13barkleythe world is not trees
23:13barkleyour models of the world is not a tree
23:13rzezeskiThe 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:13verec_I understand what you don't want. That's what toy do want I'm interested to learn about ... :D
23:13barkleyit's a graphy
23:13cadsverec, 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:13cadsd 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:14barkleycould we macro predicate-dispatch ?
23:14barkleyor do we need that with clojure?
23:15cadsI think in java or c++ we have a harsh class based hierarchy OO with multiple inheritance that can make things very complicated
23:15barkleymy point is that, i don't think in hierachiers
23:15barkleyi think in data and functions
23:15cadsin 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:15barkleyand then LATER ON i want to dispatch on it
23:16barkleyanother case of where OO is premature-optimizaation
23:16verec_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:16barkleywhy is refactoring so big in the OO world? think about that?
23:16cadsin other languages we just have object prototypes that are just lone objects that are not part of a hierarchy or inheritance
23:16rzezeskicads: 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:17barkleyrzezeski: exactly
23:18verec_barkley: I hope you see how "change method signature" van be useful, OO or not, ie even with "plain" functions?
23:18barkleyrzezeski: yes, we can "greenspun" our way around it int the OO world, but we need tools to do it
23:18cadsI like clojure but I just might have to experiment with things like maps that encapsulate object properties and functions
23:18barkleyverec_: i just brought up the tools point
23:18cadshah, for that matter, I might have to start messing around with agents
23:19barkleyand ti's just ugly with all that class boilerplate
23:19cadsc'mon barkley, enough bashing, instead of all that bashing you could be writing code or getting head, like right now :)
23:19barkleylisten, i'm not saying OO is useful...i'm saying it's been snake-oil for 20 years now
23:19barkleys/useful/not usefu/gc
23:20rzezeskinothing 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:20barkleyhere's the thing for me
23:20barkleywe talk about agaile
23:20barkleyagile
23:20barkleyhow can you be agile without a REPL?
23:20barkleyand OO by its nature makes REPL development weird
23:21rzezeskiare you saying Agile hinges on the prescence of a REPL?
23:21barkleyno
23:21barkleyit makes it a helluva lot better though
23:21verec_barkley: are you saying that people couldn't do CLOS at the REPL in CL ????
23:21rzezeskisure, but Agile is not about any particular process, it's about a mind set
23:21cadsI crash my repl too often to do development in it :D
23:22barkleyCLOS is generic-functions
23:22rzezeskithe language and tools don't matter nearly as much as the mindset
23:22barkleymuch easier
23:22cadsI'll be like "fuck! why didn't I write that last bit in a file"
23:22cadsand then have to set up the environment again by hand, that's miserable
23:22verec_CLOS is gf + objects ... at the REPL ...
23:23barkleymy whole point is that data does not belong with classes
23:23barkleybottom line!
23:23barkleyit's wrong
23:23barkleyno matter who says what
23:23rzezeskiYou 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:23verec_If data doesn't "belong to class" what does it belong to? How do you package a set of related items together?
23:24barkleymodules
23:24barkleyanother example of wrong OO premature-optimization
23:24cadsverec_: hehe, that's a good question.. how does clojure do it?
23:25barkleycads: we don't do OO?
23:25verec_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:25barkleywe got private which is defin-?
23:25rzezeskiand 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:25barkleyverec_: that's the big problem...there's impedance mismatch with the type "class" and a "module"
23:26barkleyand i'm sick of this non-static bigotry
23:26verec_barkley: what is inside any of your module? Care to give an example?
23:26barkleyverec_: all my statics
23:26barkleyVB does it right
23:26barkleyunlike C# with their retarded static classes
23:27cadsverec_: 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:27barkleyand still have to declare everything static
23:27barkleystatic should bge the default
23:27barkleynot the other way around
23:27verec_by "statics" you mean what exactly? globally accessible stuff? Some "scope protection"? What exactly?
23:27barkleyglobal?
23:27rzezeskiberkley, when's your birthday? I'm going to send you a Bertrand Meyer book :)
23:27barkleythere are no bloals?
23:28barkleyrzezeski: i don't agree with him
23:28rzezeskihaha, who does, he's French (j/king French people, I love you all)
23:28barkleywell, Meyer is better than most OO, but he's still wrong
23:28cadsverec_: 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:28barkleythat's why i hate him;)
23:29cadsare namespaces first-class in clojure?
23:29barkleycads: yes
23:29barkleywell...
23:29barkleyhmm
23:29verec_cads, are you saying that clojure namespaces is what barkley is referring to as "module" ?
23:29barkleyi'm not qualified to make that assertion of "first class"
23:29cadsverec_: I don't know what kind of module barkley is referring to, and maybe he doesn't either :)
23:30barkleycan a brother just write some code bottom up AND THEN decide if he needs OO?
23:30cadsverec_: 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:30barkleysee, ML has freaky-ass module things that are powerful
23:31barkleyor the ML family , including Ocaml
23:31cadsand even haskell lets you instantiate whole models based on parameters
23:31verec_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:31barkleyverec_: that's the whole point
23:32barkleyverec_: i guess i don't like the whole "class" concept
23:32barkleyit's just wrong
23:32verec_Yes, and your point is what exactly? I'm getting lost ....
23:32barkleyoh geez
23:32barkleywhy do we have to go through hoops to get static methods
23:32barkleyor why does "the community" tell us not to static methods?
23:33cadsverec, OO bad, groupthink bad, no use OO, evar.
23:33cadsI think that's the lesson
23:33barkleyok, in static methods in Java or C# how do they hinder testing?
23:33cadswhat's a static method?
23:33verec_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:34barkleyit's retarded that i have to concept my funcs in a namespace and a class if they're static
23:34barkleyjava is horribly wrong in that respect
23:34barkleyC# 2.0+ did the static class which was done horribly wrong
23:34cadsverec_: how do you encapsulate a collection of generic functions into a class?
23:34barkleywhich i busted one of the C# degners on
23:35rzezeskiwhere do they go then? Global lookup table?
23:35barkleyno, no
23:35barkleywe're just talking about a fucking namespace
23:35barkleywhy is so damn hard
23:35barkleyi don't want "object instances"
23:35cadsverec, it seems that encapsulating generic functions in a way that meaningfully documents how you can use those functions... is tough
23:36verec_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:36barkleyso in dotnet i have to wrap everything up in a namespace and a static class
23:36barkleyverec_: just said that
23:36barkleycan a brother just his work done without ceremony
23:36barkley?
23:36barkleyat least i get to work in C# 3.0
23:37barkleyi feel bad for Java people
23:38verec_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:38barkleywell, at least i can use anyt tool i want
23:38barkleyverec_: are you freaking kidding me?
23:38cadsblahrg, your negative energy is cramping my evening berkley, what do you wants us to help you with?
23:39cadslearn lisp, be enlightened and float above these concerns and peeves
23:39barkleycads: have you been drinking?
23:39cadsno, man, it's just... this is a clojure channel, and we've been talking OO for like an hour
23:39cadsisn't that depressing?
23:39barkleycads: i'm trying to explain to verec_ why we don't buy into the OO hype
23:40barkleythank you
23:40verec_who is *we*... Please do not include me, ok?
23:40barkleynot you
23:40barkleybrother, believe in what you want
23:40barkleyi just never bought into OO hype
23:40barkleyto each his own
23:41cadsanyways, 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:41barkleyin clojure?
23:41cadsdamn right
23:41cadshate test cases :P
23:41danleibarkley: 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:41barkleydoing some bongs and writing clojure is a good thing:)
23:42barkleygood deal bro. good talking to you cads
23:43barkleyverec_: i just don't want to debate OO
23:43barkleyverec_: sorry friend
23:43barkleyverec_: there's nothing to debate really
23:43cadsdanlei, 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:43verec_barkley: great! Let's get back to clojure then!!! :D
23:43barkleyverec_: cool friend:)
23:44barkleywhat kind of simulator you working on cads?
23:44barkleyi'd like to do my chromaky video in clojure
23:45verec_cads, what's missing from structmaps that you need for your simulation?
23:46cadsguys, 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:48verec_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:49cadswell they're supposed to be faster
23:50kadaveranyoen know of a code review forum?
23:50verec_Doesn't this sound a bit like .... premature optimization? where is your bottleneck? what have you _actually measured_ ??
23:50kadaveri have a 400loc mp3player that id like commetns on
23:50kadaverwritten in clojure
23:51cadshehe, I like premature optimization, you're thinking of the other guy
23:51rzezeskikadaver, you could put it on http://paste.lisp.org/ and then post to the Clojure group
23:51verec_cads, Is your simulator in any kind of working state at the moment?
23:52cadsno, just the vectors and the particles and be built and operated on with simple operations
23:52cadsright now I'm writing particle operations
23:52cadslet me give an example
23:53cadsright 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:55verec_So you are passing *two* map arguments to your grav function? Why not a single structmap?
23:56cadswell the grav takes two particles, each represented by a structmap
23:56verec_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:57cadsactually, I'm not too displeased with that
23:57cadsI wish I could make the destructuring implicit and save on some line noise
23:58barkleycads: i hear that alot
23:58barkleycads: "destruciting"
23:58verec_cads. you can't really get around the fact that you need to have all the operands available to your body, right?
23:58barkleywhat does that mean
23:59barkleya map into a list?
23:59barkleyjust grasping at straws here
23:59rzezeskibarkley, you know anything about pattern matching in Haskell? It's something similar.
23:59verec_barkley destructuring means pulling the _contents_ of some data structure bit by bit, only extracting those elements that are relevant