#clojure logs

2009-09-23

00:00hiredmanI don't see how that would require a useless parameter
00:00mabes|awayhow do I get the length of a list in clojure? (find-doc "length") isn't helpful.. Is length defined in some lib in clojure-contrib?
00:00hiredman,(doc count)
00:00clojurebot"([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps"
00:00killy971mabes|away: > count
00:01mabesok.. coming from scheme so I expected length. thanks :)
00:01killy971hiredman: do you know project euler?
00:01hiredmanI am aware of it
00:01killy971problem 214
00:02hiredmanI think it would help if you explained what you mean by dynamic programming first
00:02killy971it is basically about computing phi, and phi again on the result of primes upto to a certain limit
00:02killy971so
00:02killy971I have a function which compute the length of a chain
00:03hiredman~euler
00:03clojureboteuler is http://clojure-euler.wikispaces.com/
00:03mabeswhat is the general rule for deciding to use a vector vs. a list in clojure? In my case I'm dealing with integers.. is a vector a better fit for that and why?
00:03hiredmanit might help you to get a feel for clojure code if you looked over some of the solutions there
00:03killy971then, I would like to check if the chain length for a certain number has already been computed
00:04hiredmanmabes: do you require fast indexed access? if so a vector, if not, a list
00:05mabeshiredman: ok, so if I'm just iterating over them then a list is the best fit. Thanks.
00:06hiredmankilly971: sounds like a job for reduce
00:07hiredmanyou have a map which is a cache, and you would like to reduce a list of numbers to entries in the cache
00:07killy971I see
00:08killy971I am going to try this
00:08killy971thanks
00:08hiredmanconviently enough, reduce used in this fashion will work with or without transients
00:09hiredmanclojurebot: transient?
00:09clojurebotexcusez-moi
00:10hiredmanclojurebot: transients?
00:10clojurebotNo entiendo
00:10hiredmanclojurebot: transients is <reply>http://clojure.org/transients
00:10clojurebotAck. Ack.
00:16technomancykilly971: you shouldn't be using transients unless you've already written a non-transient version of the same code, profiled it, and found it to be a bottleneck
00:16hiredman
00:16killy971well, I was trying it for the first time as it seemed convenient...
00:16killy971but I know I shouldn't use this
00:17killy971in the first place
00:33mabeswhen I want to define a helper function in another function is the best way to do so is with let? (this is what I did: http://github.com/bmabey/sicp-study/commit/1306fe6a76968e28bbd36df5e79e0edf56ee7696)
01:10woobyhello, i'm new and looking for cool web app clojure stuff... i saw compojure, are there other projects of note?
01:12mikemwooby: there's also conjure: http://github.com/macourtney/Conjure
01:12woobymikem: thanks i'll check it out
01:14woobyoh, i'm in the middle of that guy's book
01:14woobyerr nevermind
01:45dnolenis there a way to say that an fn is synchronized for a Java primitive parameter/object as you can for methods in java?
01:51cgrand~locking
01:51clojurebotNo entiendo
01:51cgrand,(doc locking)
01:51clojurebot"([x & body]); Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances."
01:51cgranddnolen: that's the closer thiing I can think of
01:53dnolencgrand: interesting! thanks, so that should work pretty much the same way?
01:56dnolencgrand: that's close enough. only one thread can enter that block of code. I guess synchronized syntax generates something pretty much like that.
02:16licoressegood morning europe
02:42prospero_,(= (keyword "a") (keyword 'a))
02:42clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String
02:42prospero_hmm, that's not what I get at my repl
02:43prospero_anyways, the above returns true for me, but (= (keyword "/") (keyword '/)) returns false
02:43prospero_anyone know why?
02:45hiredmanuh
02:45hiredmankeyword takes a string
02:45prospero_I dunno, I pulled from github a few days ago
02:46prospero_it seems to not mind symbols
02:46hiredmanI guess that changed
02:46hiredmananyway '/ is treated somewhat special
02:47hiredmanI imagine it would not be allowed as a symbol at all (just as namespace seperator) if it wasn't for / as the division op
02:47prospero_right, I'm just trying to set up some rules for a DSL
02:48prospero_and while it refuses to read :/, it will take (keyword '/)
02:48hiredmanfor good reason
02:48hiredmanin a keyword is a namespace seperator
02:49hiredman,:foo/bar
02:49clojurebot:foo/bar
02:49prospero_oh, ha
02:49prospero_that makes sense
02:49hiredman,(namespace :foo/bar)
02:49clojurebot"foo"
02:49hiredmanis special, so it is best not to use it
02:49hiredmaner
02:49hiredman/ is special, so it is best not to use it
02:50hiredman(my irc client ate / the first time)
02:50prospero_like I said, it's for a DSL, so I don't have much choice, unless I don't allow division
02:50hiredmandiv
02:50prospero_every other arithmetic operator is a symbol
02:50hiredman:\
02:50hiredman,:\
02:50clojurebotInvalid token: :
02:50hiredmananyway, those are the breaks
02:51prospero_well, doing (keyword '/) seems to work fine
02:51prospero_is that going to change?
02:51prospero_am I just lucking into some implementation detail?
02:51hiredman~search ticket keyword validation
02:51clojurebotNo entiendo
02:51hiredman~ticket search keyword validation
02:51clojurebot("#6: GC Issue 1:\t:validator as keyword arg for ref/atom/agent" "#17: GC Issue 13:\tvalidate in (keyword s) and (symbol s)")
02:51hiredman~ticket #17
02:52clojurebot{:url http://tinyurl.com/nq6ef7, :summary "GC Issue 13: validate in (keyword s) and (symbol s)", :status :test, :priority :low, :created-on "2009-06-17T18:56:26+00:00"}
02:52prospero_so basically if :/ doesn't fly, neither should (keyword '/)
02:53prospero_is that what you're saying?
02:53hiredmanyep
02:54prospero_I'm confused, though. It looks like the fix for this issue was already submitted
02:54prospero_so why is my workaround still working?
02:55hiredmanthere is a patch for testing
02:55prospero_which hasn't been merged yet
02:55prospero_ok
02:58sfuentesquestion: as i'm here trying to learn clojure I get the feeling that I'm writing code in clojure but not necessarily functional code. My gut instincts is to remind myself to try to use map and reduce as often as possible. Is there a better approach to trying to learn functional programming?
02:59hiredmanpractice practice practice
02:59sfuentesi imagine that there is more to functional programming than just map and reduce
03:00hiredmanwell, use and write functions
03:01arbschtthere are book, if you're into that sort of thing
03:01arbschtbooks
03:05sfuentesok so here's my naive plan: code, code, read more about FP, code, code some more, read other ppls code, code, code ... etc
03:06RaynesA good way to learn functional programming, if you find it impossible to grasp it otherwise, is to learn Haskell. You'll walk away from Haskell all starry-eyed, and you'll be a new man. Clojure will look like a golden halo floating just inches above the top of a redwood stand waiting for you to pick it up and place it upon thy skull.
03:06RaynesOne ring to rule them all...
03:07arbschtmorning LauJensen
03:07Raynes:D
03:08sfuentesWell I did consider learning Haskell ... but I questioned how practical it would be.
03:10arbschtit's quite practical. however I don't see why you might not just learn clojure. you'll face similar challenges learning functional patterns in both systems
03:10Fossiit's a bit like learning lisp, no matter what language you code, it will teach you some
03:10yasonsfuentes: in Clojure you'll generally find yourself having to do more work if you want to stay out of functional style
03:11LauJensenMorning arbscht :)
03:11LauJensen(and the (rest #clojure))
03:11yasonsfuentes: nevertheless, there's no best way to learn functional programming: you'll get it eventually, one way or another, as long as you delve into it
03:12LauJensenyason: that statement is probably wrong - we just have worked out the best way yet :)
03:13yasonLauJensen: there's probably always a best way for one person, but nothing that caters for everyone
03:13yasonLauJensen: not until humanity turns into a horde of similarly wired clones, anyway :)
03:13LauJensenlike I said, we're working on it :)
03:14crioshello. I think a good way to learn functional programming is to read the source code written by their power users, so that one can also study the "best practices" suited for that language
03:14LauJensenTrue, thats a good way to go
03:15criostherefore, I'm in search of a good code base. Do you suggest anything in particular, on "clojure-contrib" perhaps?
03:16sfuentesyeah, good examples of functional code would help
03:16LauJensen~def println
03:16sfuentescause i feel like i don't know what i'm doing
03:16LauJensensfuentes: Read that file, it's called core.clj, lots of good stuff :)
03:16sfuenteswill do
03:17sfuentesits like i hear ppl talking about orgasms and not having experienced one
03:17LauJensen...
03:17yasoncrios: I somehow "got it" when writing C... I had been toying with Emacs Lisp for years but finally realized that if I pretty much inline everything instead of using variables, recompute them, and pass them as variables, then my C code actually looks like the code I had been writing in ELisp... :)
03:19crios_clojurebot: logs?
03:19clojurebotlogs is http://clojure-log.n01se.net/
03:20crios_[come back from a Firefox crash]
03:21crios_mmm in the history I don't see the last sentences
03:21crios_could you re-copy the url?
03:21Fossi~def println
03:22Fossiit's just core.clj
03:22Fossi"just"
03:22crios_:)
03:22pixelmanI'm looking for a good and clean way to replace keys in a string in clojure from a map, like "hello $bar" {:bar "world"}
03:23crios_ ~def identity
03:24crios_~def
03:24clojurebotdefmulti doc is ugly
03:24crios_just trying "~def"
03:27LauJensen,(reduce #(.replace %1 (name (key %2)) (val %2)) "foo $bar baz" {:$bar "baz" :baz "bar"})
03:27clojurebot"foo bar bar"
03:31LauJensenpixelman: Clean ?
03:32pixelmanLauJensen: thanks! I it's clean :)
03:33LauJensennp
03:36crios_anyone here use VI on Linux?
03:37crios_links on how enable clojure support?
03:38LauJensencrios_: Its quite easy "sudo apt-get purge vi* && sudo apt-get install emacs-snapshot && git clone git://technomanchy/clojure-mode"
03:39crios_emacs?
03:39arbschtcrios_: I think this is a usable solution http://kotka.de/projects/chimp.html
03:40crios_ok, I'll give it a try , thank you
03:40hiredman~vimclojure
03:40clojurebotvimclojure is state-of-the-art
03:40hiredman~google vimclojure
03:40clojurebotFirst, out of 245 results is:
03:41clojurebotKotka : Projects : Clojure : VimClojure
03:41clojurebothttp://kotka.de/projects/clojure/vimclojure.html
03:41arbschtah that's the one
03:41hiredmanchimp is superseded
03:41crios_ok, let's go with vimclojure :)
03:49LauJensenI can't find the *agent* thing documented anywhere, why is that ?
03:56arbschthttp://clojure.org/api#toc9
03:57LauJensenarbscht: thanks
04:22LauJensenDoes anybody have a really easy-to-follow beginners guide for emacs/slime?
04:23arbschtLauJensen: there is a builtin tutorial. hit C-h t
04:24LauJensenI meant for setting up slime though :) I wan't something for non-clojurians who read my blog, so they can get setup really quickly
04:26tomojjust found this http://acidrayne.net/?p=39
04:26tomojif you use the emacs-starter-kit it's really easy
04:26arbschtLauJensen: oh, I believe it's as simple as M-x clojure-install, once clojure-mode.el is installed
04:26LauJensenGreat, thanks
04:26LauJensenOk, even better
04:26tomojyeah, clojure-install is easier than the manual thing I linked to
04:27arbschtLauJensen: http://technomancy.us/126
04:31LauJensenarbscht: great, really clear and easy to follow, thanks
04:47sfuenteswhat does & in an argument vector mean?
04:49arbschtsfuentes: the remaining arguments
04:49arbscht,((fn [a & more] [a more]) 1 2 3 4)
04:49clojurebot[1 (2 3 4)]
04:51sfuentesi see. thank you.
05:03simplechatheyyas
05:05Chousukehi
05:06simplechatjust as a question, on debian say, what would be the easiest way to set up a useful clojure environment?
05:12LauJensensimplechat: http://technomancy.us/126
05:19crios_I'm wondering how burden it is installing vimclojure. Recompile clojure-contrib, use ANT to get the vimclojure jar, start a ng-server server, and finally tell VI to use that NailgunClient!
05:19crios_Just thinking it was a joke :D!
05:20crios_so I must checkout the "contrib" source
05:20crios_can I "svn" it?
05:21crios_Or should I use just git?
05:21LauJensenhehe
05:21LauJensenYou should use Git for any and all SCM purposes, especially however, Git repositories
05:21djpowellthe new ->> is nice
05:22crios_lol. So in order to configure vi I have to install git, too. ehehe. Ah, these programmers! ;)
05:23LauJensen(doc ->>)
05:23clojurebotI don't understand.
05:23LauJensendjpowell: ?
05:23djpowellit has just been added in git
05:23djpowellit is like ->, but it threads the last parameter
05:24djpowellso you can do (->> (range 1 7) (filter odd?) (map #(* 2 %)) )
05:24LauJensenah ok
05:35LauJensenFor those interested in concurrency http://www.dzone.com/links/concurrency_challenge_dining_philosophers.html
05:38crios_btw, LauJensen, why do you think I should ALWAYS use git?
05:40LauJensencrios_: Where SCMs are concerned I far prefer the distributed approach. Regarding implementations, Git is 1) Much more effecient, which gives a faster workflow, 2) Better integrated into Emacs (Magit/egg) 3) Has a few more tools (maybe not anymore though), like git bisect. 4) Branching is redundant in SVN/CVS but comes to great use in Git
05:40Chousukeredundant is not the right word. "pain" is better :P
05:41LauJensenhehe, true
05:41crios_regarding the fourth point it is difficult to not agree :)
05:41Chousukegit makes branching natural
05:42crios_It should be the real reason for which I would leave svn
05:45crios_this is my experience: suppose two branches, feature1 and feature2. I have to freeze a release, so a create a new branch release1, merging both. Then, when I'll have to merge that features in trunk (for example), I cannot merge release1 with trunk: I must restart the merge using feature1 and feature2 branches towards trunk!
05:45crios_[when using svn]
05:50jdzsomebody's been using too much syntactic sugar
05:50LauJensenwho?
05:50jdz(map #(agent %) (repeat 5 0)) => (map agent (repeat 5 0))
05:51LauJensenoooh :)
05:51LauJensenI got caught red handed didn't I ? :)
05:51sgtarrLauJensen: you're behind bestinclass?
05:52LauJensenYes
05:52sgtarrBasically, you're to blame that I'm now back to looking at Clojure instead of Scala ;)
05:52LauJensenHaha :) You read the concurrency post did you? :)
05:52sgtarryep
05:52LauJensenMan I'm glad to hear that, welcome to :)
05:55jdzLauJensen: does the program work at all?
05:55LauJensenjdz: The dining philsophers? Yea it runs flawlessly
05:55jdzyou use @forks in the code, although forks is just a sequence
05:56LauJensenlemme look, might be some cut'n'paste which got mangled
05:56LauJensenGood catch, thats version 0.1 code :)
05:57LauJensenI started with (ref {:1 true :2 true...} but went with n-refs after cgrand spanked me
05:58jdzalso, there's something wrong with: I can pull id [id (dec id]
05:58jdzmost probably missing paren before closing ]
06:00jdzi'd define a function fork-available? and then use that as the first parameter to every? in got-forks?
06:00LauJensenthats a weird sentence alltogether
06:00LauJensenjdz: You think that would make it more clear?
06:01LauJensenI went with this because got-fork? was a fun parody on 'got milk?' :)
06:01jdzwell, that's good software practice if you later decide to represent forks differently
06:02jdzand i dislike #() sin-tax [with a little passion]
06:02LauJensenMan you get annoyed quickly
06:02jdzin general, #(= true (second %@)) in no way tells me what it's supposed to mean
06:03jdzhence the code is not readable
06:03LauJensen%@ is ugly, I've changed to (deref %)
06:03jdzand hard to grasp if i have to jump all over the program to look what my-forks returns, and then go looking what is in the forks sequence etc
06:04jdzchanging to deref does not change the point
06:04jdzthe code is not self-documenting
06:04jdzas opposed if you used the fork-free? predicate
06:04jdzjust try reading the body of the function with my suggestion and your original version
06:05Chousukeisn't the (= true ...) a bit redundant? or is it possible to have values that are logically true but should return false with the test?
06:05LauJensenYou have a point jdz, but I think code-length can itself add a factor of unclearness to the code. Generally ½ line abstractions are to be avoided I think
06:06LauJensenChousuke: It's for new-comers
06:06LauJensen(which I think my site has 92% of)
06:06jdzLauJensen: see, Chousuke also has a point. and his objection is not related to the got-forks? function, but to fork-available?
06:07LauJensenI see that
06:12ChousukeI think you could make it a lot cleaner if your fork data structure was a map instead of a vector
06:13LauJensena map of refs ?
06:13jdzand why is the fork vector in a ref when it's the second member that's changing?
06:13jdzi.e., the fork id never changes
06:13LauJensenyea thats redundant
06:15Chousukeif you had {:fork-id % :free? true}, then the controversial lambda would become #(:free? (deref %))
06:16LauJensenyea - I think I might need to release a 2.0 in a couple of days :) I built a model quickly and then added to it. To a degree this hasn't been ideal
06:46hamza`hey guys, which notation is prefered i use (new SomaClass) mostly but i see code using (SomeClass.) notation which one is more idiomatic?
06:47LauJensenlast
06:47hamza`kk thx.
06:53ambienthttp://bitumenframework.blogspot.com/2009/09/benefits-of-using-clojure-lisp-in.html
06:54ambientbtw, are rich hickey's jvm summit talks anywhere online?
07:04y-combinatorHello. What is the easiest way to convert Clojure hashmap to java.util.HashMap?
07:04LauJensenambient: I wonder why it tarries
07:05ambientLauJensen not following you
07:06LauJensenambient: I wonder why it's not up yet
07:06ambientyep
07:07LauJensen,(java.util.HashMap. (hash-map :a 5))
07:07clojurebot#<HashMap {:a=5}>
07:08LauJenseny-combinator: I think that's as easy as it gets
07:10y-combinatorLauJensen: thank you
07:10LauJensennp
07:32AWizzArdAnyone here who runs Compojure behind https?
07:32AWizzArdLauJensen?
07:33LauJensenYea, one of my applications is on https
07:33AWizzArddid you configure Jetty for that? Compojure ships its own jetty, and that is just a .jar file. No config files etc.
07:34AWizzArdOr do you have an Apache on port 80 with ssl support which simply transparently proxies your request on a jetty on localhost?
07:38LauJensenSince it was for 2 clients we put an apache in front of it. Only one of 2 clients wanted https
07:38LauJensenNext time I'll opt for nginx though
07:38crios_does anoyone know what does it mean "clj_want_gorilla" when configuring vimclojure?
07:39jdzmust be something every vim user knows :/
07:40simplechatSo compojure is clojure for webapps?
07:40AWizzArdLauJensen: nginx for more simplicity in the setup?
07:40LauJensenyes, once you know what you're doing it takes 5 minutes to setup, and I have a hunch that it's more effecient
07:41AWizzArdsimplechat: Compojure is a lib with which you can (easily) write webapps in Clojure.
07:41LauJensensimplechat: it's one way to go
07:41simplechatvery cool :)
07:41simplechatany nice tutorials?
07:41simplechatLauJensen, any other good ones?
07:41AWizzArdthere already are severals
07:41simplechat(that you'd recommend)
07:41AWizzArdtutorials
07:41LauJensenno :)
07:41arbschtbeware many of the tutorials are now obsolete
07:41simplechatnone that are worthy of recommendation?
07:42LauJensensimplechat: I looked at technomancys concourse git repo on Github, that's the only 'tutorial' I've had :)
07:43ambientdoes compojure have a remotely stable api yet?
07:44arbschtambient: I think so
07:44LauJensensimplechat: They might exist, but Compojure is Rock solid and James Reeves (one of 2 core developers) does some amazing work, so I have no reason to look around
07:44LauJensenambient: I think so, but you might want to ask on the group
07:44ambientit would be cool to try it but can't help thinking i'm wasting my time if i have to learn to do it in a completely another way later
07:44ambientok
07:44simplechatvery cool :)
07:44LauJensenambient: I think the main function you'll be using (html [:h1 "My header"] [:p "My paragraph"]) isn't likely to change
07:45simplechatcan you get a repl on the server?
07:45arbschtsimplechat: certainly
07:45LauJensenYep
07:45simplechatOMFG :)
07:45simplechatarbscht, how?
07:45arbschtsimplechat: as with CL, you may load swank into the server process
07:45simplechatswank?
07:46arbschtor you could launch the server in a screen session
07:46arbschtclojurebot: swank-clojure
07:46clojurebotclojure is the bestest programming language available.
07:46jdzor just use eval to evaluate code from random people that will destroy your server
07:47arbschthttp://github.com/jochu/swank-clojure
07:50simplechathey arbscht i can imagine that would be absolutely awesome
07:50simplechatso you code on your server, which is then running actual code which is web accessable?
07:51LauJensenJust thinking out loud - If you have a repl running on a live server system, it would be possible to through nmap to discover that and break in quite easily.
07:52simplechatLauJensen, well you'd secure it
07:52arbschtLauJensen: bind it to localhost and connect via an ssh tunnel
07:52arbschtsimplechat: you could do that, but preferably not on a production server :)
07:52simplechatlike i have a VPN to my servers so i'd just only expose it via the vpn
07:52simplechatarbscht, am i the only person who would call this profanity worthy?
07:52LauJensenarbscht: Yea something like that - All I'm saying is, don't let the door open
07:53simplechatLauJensen, note taken
07:53LauJensensimplechat: nothing is ever profanity worthy
07:53ambienta simple ssh shell wouldn't suffice?
07:53simplechatLauJensen, in the "This is [x]ing cool"
07:53simplechattype of sense
07:53simplechatassuming i can get it working
07:53ambientdon't bind the repl to anything
07:53simplechatand learn emacs
08:05Fossidoes proxy return a value even if the interface is defined void?
08:10Chousercalling any void Java method returns nil, whether it was defined by 'proxy' or not.
08:33jowagdoes anybody know what is the license on the clojure logo? Or is it trademarked?
08:36ChouserI don't think it's trademarked. rhickey generally gives permission for any use related to the Clojure language.
08:38pixelmanhahaha the sound on this page http://java.ociweb.com/mark/clojure/
08:39ambientapple quicktime addon? no thanks :/
08:39ambientcan't you just directly link to the midi file?
08:40Chousermidi?
08:40Chouserthere are links at the bottom of the page to the .mp3s
08:40ambientoh, it was some mp3's
08:40ambienti wonder what the qt stuff is for
08:41pixelmanit autoplayed in my mac
08:41ambientheh, i miss the times when half of the personal web pages had some cheesy midi file playing in the background :p
08:42Chouseronce I turned on JavaScript it autoplayed here on Ubuntu
08:42ambientwell it's quicktime, so totem/mplayer/whatever might have it
08:42ambientbut windows vista needs it to be manually installed
08:53djpowellInspired by this: <http://www.rubyinside.com/hijack-get-a-live-irb-prompt-for-any-existing-ruby-process-2232.html&gt;, I put together something similar for clojure. It takes a process id, and uses the Java 1.6 Attach API to start a clojure repl up in that process, and lets you type stuff into that repl. I'll have to remember to publish it somewhere if anyone's interested.
08:54pixelmanawesome! I've been wanting to do that in clojure
08:54eevar2djpowell: how does it compare to swank?
08:54eevar2swank-clojure, that is
09:00simplechatdjpowell, i'm interested
09:02pixelmanare closures thread safe?
09:04Chousukepixelman: well, they're supposed to be immutable so... yes? :/
09:04pixelmaneach thread keeps it's own references?
09:05Chousukewhat do you mean?
09:05Chouserdjpowell: wow sounds amazing.
09:05pixelmanI assume they are thread safe, I just try to understand how it is done
09:05Chousera closure can certainly do thread-unsafe things
09:07Chousukepixelman: the closure saves a references to the objects in the outer scope that you use within the closure. if the things are immutable, you can't have threading problems. :)
09:07Chousukeof course you can always capture a reference to something mutable
09:07Chouseror pass in a mutable thing
09:08pixelmanok!
09:08pixelmanbut for each thread the arguments passed to the closure are the threads own?
09:08Chouserclosures are independent of threads
09:09pixelmanuh
09:09Chouserthe arguments passed to a closure are whatever arguments you pass to it
09:10crios_,(clojure.contrib.repl-utils/source cons)
09:10clojurebotjava.lang.ClassNotFoundException: clojure.contrib.repl-utils
09:10crios_mm
09:10Chouser~def cons
09:11Chouserstill not very helpful. cons just calls clojure.lang.RT/cons
09:11crios_whati is it "(fn* cons"
09:11crios_?
09:11crios_fn* ?
09:11Chousercrios_: that's clojure code before most of clojure has been defined yet. :-)
09:11simplechathey, i know this is probably stupid, but how do you implement a counter as a clojure?
09:12Chousercrios_: fn* is currently just like fn but without support for destructuring, :pre/:post, etc.
09:12Chousercrios_: but that's an implementation detail. note that at that point in core.clj, not even 'defn' is defined yet.
09:13crios_thaks Chouser. Yes, I'm trying to "study" / read core.clj source code
09:13crios_maybe some more simple code base should be appropriate^
09:13Chousersimplechat: you want the closure to change some state each time it's called?
09:13Chousukesimplechat: depends on what you need to count
09:13Chousukesimplechat: a ref is good, or an atom
09:13Chousercrios_: reading core.clj can be quite instructive, just keep in mind that much of what it does early on can be done more easily later.
09:14simplechatChouser, yep
09:14Chousukesimplechat: or in some cases, just a regular function parameter
09:14simplechatChouser, just a number
09:14Chousukesimplechat: sure, but for what use? :)
09:14crios_ok Chouser
09:14simplechatChouser, more information?
09:14Chousukehm
09:15simplechatuh, Chousuke
09:15Chousersimplechat: if you want some mutable state, you need a reference object to hold that state. Like Chousuke said, an atom or ref would be a good choice.
09:15Chousukesimplechat: do you need a global counter for something or just count something within a loop?
09:16pixelmanmy question re closures is if something like this would be thread unsafe: (defn unsafe? [x] (fn [y] (let [z (+ 2 x)] (+ z y)))) i.e. having a let in a closure.
09:16simplechatChouser, global counter
09:16Chousukepixelman: no
09:17pixelmanChousuke: tnx
09:18Chousukepixelman: unless x is mutable at least. which it won't be if it's a number
09:18pixelmanbut then I would have to wrap it in a transaction?
09:18Chousukehm
09:19ChousukeI don't really know
09:19Chousukesomething like (defn foo [a] (fn [x] (aset a 0 x))) would be unsafe
09:19Chousukebecause a is mutable
09:19Chousukebut that's not really a closure problem
09:20Chousukethat's a problem with a being mutable :)
09:20pixelman:)
09:31manic12this could be a java question, or it might also have to do with clojure under slime, but how does one debug threads running other than the repl?
09:32manic12how does one even get a list of running threads for that matter?
09:34crioshelp on thi expression: (. clojure.lang.RT (cons x seq))
09:35criosthe second member (cons ...) should not be a method in clojure.lang.RT ?
09:35Chousercrios: same as (clojure.lang.RT/cons x seq)
09:36criosah, ok, it is a static method
09:38Chouseryes
09:38Chousukethat's "old style" code though. don't imitate :)
09:39criosok boss :)
09:42manic12anybody know of some good docs to look at for basic threading stuff?
09:45criosmanic12, mabye on Sun's site
09:45crioshttp://java.sun.com/docs/books/tutorial/essential/concurrency/
09:46manic12thanks
09:47crioswhen one should use the ":arglists" metadata when defining a new function?
09:48Chousukeit's a documentation thing
09:48Chousuke(doc defn)
09:48clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
09:48Chousukeyou can make it look like that if you want
09:48Fossiconfusing?
09:50criosthat documentation hint is used by automatic doc-gen tools? Why should be not enough to parse the content of [ ] ?
09:52Chousukewell, :arglists defaults to the argument vectors :P
09:52Chousukebut you can override it if you want to be more specific
09:53jdzcrios: if you look at the definition of defn you'll see none of the arglists mentioned in documentation
09:53criosthat is if I just want rename a paramter?
09:53criosyes jdz
09:54jdzin case of defn it does a bit of argument processing (restructuring if you will)
09:54jdzso it has only one named (positional) parameter
09:54jdzthe rest are picked out automagically
09:56criosso defn add :arglists metadata automatically, picking that information from the input parameters. If I want, I can override that behaviour with my own names
09:57jdzno, it does not add anything automatically.
09:58jdz:arglists is provided by the author of the definiton
09:58jdzdefinition even
09:58criosmmm so why Chousuke say ":arglists defaults to the argument vectors" ?
10:00jdzbecause that's true :)
10:00jdzi was a bit confused about your question. your conclusion was right in this sense.
10:02jdzit's not "overriding behaviours", but just providing data manually...
10:02criosdo all function have an arglists metadata?
10:03jdzit would be a nice exercise for you to write a function that finds that out
10:05criosmmm a function which get a function name as parameter, then search for that metadata?
10:06tmountainyou can walk through a namespace to determine what functions are available
10:06jdzyou can get all vars in the namespace, you can determine if the value of a var is a function, you can get the metadata, etc
10:06jdzyou have all the tools
10:10crioswait. I know that not all functions are declared with :arglists. But when they are evaluated/compiled at runtime, that metadata is not added automatically?
10:11criosbtw, the private function 'sigs' have no arglists declared
10:15RomanRoewhy does (.getClassLoader java.util.Map) returns nil? Any other chance to get the classloader?
10:18criosmaybe you should wrapp that with class
10:18RomanRoe(.getClassLoader (class java.util.Map)) => nil as well
10:32hiredmanthe javadoc for Class says some implementations may use null to represent the bootstrap classloader
10:41RomanRoeah, thanks for pointing that out! I switched to (ClassLoader/getSystemClassLoader) which is correct for java.util.Map
10:53tmountainis the download link on clojure.org supposed to still point to code.google.com rather than github?
10:54weissjtmountain: i don't think github has builds on it, just source to build yourself. i could be wrong about that, but i think the current release really is on google code
10:55tmountainweissj: ok, just checking. for some reason I thought the whole project was moved to github.
10:55weissjtmountain: i know the discussion is still in google groups
10:56arbschtand issues are on assembla
10:56tmountainok, I see what you guys are saying
10:56hiredman~github
10:56clojurebothttp://github.com/richhickey/clojure/tree/master
10:59tmountainI'm looking at core.clj right now. It's amazing how accessible it is in contrast to other language source I've perused.
11:18Chouserwhat's the name of that java lib that lets you create html/dom widgets in the browser?
11:20cgrandChouser: the one that uses webkit?
11:20Chouserno, it runs in a web server and generates javascript and stuff
11:20Chouserit had some generic-sounding name
11:21cgrandChouser: ah sorry, I read your question too quickly
11:22cgrandjwt?
11:23cgrandhttp://www.webtoolkit.eu/jwt
11:23Chouseryes! perfect, thanks.
11:36manic12in java, to get a list of threads, you have to enumerate the root thread group recursively, passing it an array allocated with enough space for all the threads, however between the time you ask how many threads there are and call enumerate the number of threads could change, is there something wrong with this picture?
11:37manic12is there a without-interrupts in clojure, or better yet a function already written to list the threads?
11:37Chouserwhoa
11:38Chouser,(keys (Thread/getAllStackTraces))
11:38clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getStackTrace)
11:38Chouserbah. Anyway, that should produce something like what you want.
11:39manic12what happens if you type ,(System/exit 0) to clojurebot ?
11:40stuartsierra,(System/exit 0)
11:40clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
11:41manic12thanks guys
11:45crios,(fn? #'read-line)
11:45clojurebotfalse
11:45manic12what I'd really like is if an exception were thrown in one of my window callback threads it would open and interactive clojure repl on that thread (with the ability to continue from that error of course)
11:45crios (fn? read-line)
11:45crios,(fn? read-line)
11:45clojurebottrue
11:46Chouser,(ifn? #'read-line)
11:46clojurebottrue
11:46crioswow
11:46Chousermanic12: you must be a lisper
11:46manic12how else am I supposed to debug?
11:47Chousermanic12: It might not be impossible, but I think would require essentially writing a java debugger in clojure. could be fun!
11:47manic12poke at the black box until it spits something out
11:47Chousermanic12: many (most?) java debuggers work on clojure, like jswat.
11:48manic12so I should google jswat
11:48Chousersure. or jdb which comes with the jvm
11:50manic12do you start clojure in the debugger or something?
11:51Chousermanic12: hm, I hardly ever use it. I think you can attach the debugger afterwards.
11:53rhickeymanic12: if you start Clojure with the right flags you can attach a standard Java debugger at any point
11:53rhickeyhttp://clojure.org/getting_started
11:55rhickeymanic12: it is definitely a different experience vs Lisps which monitor their own evaluation
11:56lisppaste8crios pasted "untitled" at http://paste.lisp.org/display/87561
11:57crioswell I tryied to write a function which parse all clojure.core vars
11:57criosand get only the functions that don't have :arglists
11:57crioscould you give it a look?
11:57ChouserI guess java debuggers run in their own jvm and process, not in the same jvm process as the code they're debugging?
11:58Chousercrios: 'ifn?' is true for every var
11:59criosbtw, debuggers can attach to another process, but live into their own process
11:59Chousercrios: you'd need to deref the var and use 'fn?' or 'ifn?' on the result
12:00criosI was suspecting that. In fact, it was return *in* too
12:00criosso deref..
12:00criosdo you mean (deref ?
12:01Chouseryup
12:02crios,(fn? (deref #'read-line))
12:02clojurebottrue
12:02criosok
12:02criosgoing to rewrite..
12:03crios(meta does not need deref?
12:03Chousernope, not even close. :-)
12:03criosmmm this is the trouble :)
12:06lisppaste8crios annotated #87561 "with deref" at http://paste.lisp.org/display/87561#1
12:06criosnew version, but don't work: "java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IDeref"
12:06Chouseralso note that the values of ns-map are not symbols but vars
12:07Chouseroh
12:08Chouserhm
12:08criosso do you mean that I cannot deref it?
12:08Chouserno, that's not what I mean. I just mean my-symb is misnamed. my-var would be more accurate
12:10criosok. but with this version I get an Exception: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IDeref
12:10criosjust trying to understand it
12:10Chouserhm, actually ns-map also has values that are not vars: imported classes are included
12:10Chousermaybe try ns-publics instead of ns-map
12:11crioswith ns-publics: java.lang.IllegalStateException: Var clojure.core/unquote-splicing is unbound.
12:12Chouseryeah, not all vars have values. :-)
12:13Chouserso ... once all the bugs are fixed, I'm getting an empty seq.
12:15crioswhat vars have no value?
12:15Chouser(def foo)
12:15Chouserones like that
12:15criossure
12:15criosmm
12:16hiredmanthis is why using for can get messy
12:16Chouser,(filter #(and (.isBound %) (fn? @%) (not (:arglists (meta %)))) (vals (ns-publics 'clojure.core)))
12:16clojurebot()
12:16hiredmaninstead of chains of maps and filters and takes
12:16criosso a "best practice" would be avoiding (for ?
12:17ChouserI don't see how 'for' is any worse in this case.
12:17Chousera little wordier, perhaps, since this is really just a single filter.
12:18hiredmanChouser: if you write something like (-> x ((partial map fn)) ((partial filter fn1)) ...) it is much easier to swap stages in and out
12:20Chouserhmmm
12:22criosin my example using the for, how could I use isBound?
12:22criosis it an instance method of Var?
12:22Chouserjust add :when (.isBound my-var)
12:22Chouseryes
12:23criosthanks
12:23criosgoing to rewrite
12:26lisppaste8crios annotated #87561 ""bound" check" at http://paste.lisp.org/display/87561#2
12:26criosok now works
12:27criosquerying ns-interns returns just a function
12:31Chouserah, 'sigs'? that appears to be a private var
12:39criosyes, sigs
12:40criosso all the functions have arglists.
12:40criosstill I cannot understand why :D
12:46hiredmaneh?
12:46hiredmanfn objects don't have arglist metadata
12:47hiredman~ticket search Fn metadata
12:47clojurebot("#140: Single :tag for type hints conflates value's type with type of return value from an invoke" "#12: GC Issue 8:\t:default as keyword arg to defmulti")
12:47hiredmanbah
12:47hiredman~ticket search fn metadata
12:47hiredmanclojurebot: well?
12:47clojurebot("#140: Single :tag for type hints conflates value's type with type of return value from an invoke" "#12: GC Issue 8:\t:default as keyword arg to defmulti")
12:47clojurebotNo entiendo
12:47hiredman~ticket search metadata on fns
12:47clojurebot("#94: GC Issue 90: \t Support metadata on fns")
12:48hiredman~ticket #94
12:48clojurebot{:url http://tinyurl.com/mgjunh, :summary "GC Issue 90: Support metadata on fns", :status :new, :priority :normal, :created-on "2009-06-17T20:43:34+00:00"}
12:48hiredmanany arg list metadata comes from the vars that hold the functions
12:51criosI understand your point: you say that the metadata is owned by a Var, not by a IFn
12:55hiredmanowned?
12:55hiredmanI guess
12:55lisppaste8crios annotated #87561 "the metadata is in the Var, not in the function" at http://paste.lisp.org/display/87561#3
13:01criosso this was the reason of why the Var needed a defer in order to pass its value (a function) to (fn? ); whereas the (meta does not need a defer, because it was applying on the Var itself
13:02hiredmanyes
13:03crioswow. this is the most important day of my life!
13:03crioseheh
13:18savanniWhen did the increase happen? I contributed myself to it last night.
13:19Chouser~max
13:19clojurebotmax people is 176
13:19Chouserthat's holding steady, isn't it?
13:19RaynesI don't know. I just happened to notice that there is like 40 more people than usual in here.
13:19RaynesI've not looked the channel number in quite a while, but it's not been that long.
13:19ChouserAWizzArd's been saying we should expect it as schools start up again
13:20RaynesGood point.
13:37slyrus_perhaps other #lispers came over after seeing rhickey's boston video
13:38Chouserwas there a recent boston video?
13:38ChouserI thought the most recent was JVM language summit. I assumed that was in California.
13:39savanni"Functional Programming with Clojure"?
13:39savanniOh, nm, that's by someone else.
13:42hiredmandid the video from the semantic web thing ever get put up?
13:49slyrus_Chouser: http://clojure.blip.tv/file/1313398/
13:50technomancysavanni: that was me. =)
13:50savanniCool!
13:51Chouserslyrus_: ah, that one. I think that's from late last year.
13:51ChouserBut on the internet, content lives forever!
13:52savanniThanks for the link.
14:06mccraigliebke: i'm getting a missing dependency on jung on incanter/master
14:09liebkejung?!
14:09liebkewow
14:10liebkeI removed that dependency a long long time ago, let me see if I can figure out the problem
14:10mccraigyeah, graphs.clj imports a load of jung classes as far as i can see
14:10mccraighmm
14:10liebkeah, I thought I removed graphs.clj...
14:11mccraigah, hold on... i should be using charts.clj
14:11liebkenope, it's still there... I'll remove it from the distribution
14:11mccraigdoh :)
14:11liebke:)
14:11liebkeI still need to remove graphs.clj, thanks for pointing that out :)
14:12mccraigyr welcome
14:13mccraighave you considered splitting core, so that it doesn't initialise swing ? would perhaps make it a bit friendlier for backend use
14:15liebkeyes, I think that's due to a single reference I have to a Processing class. I would like to fix that.
14:18mccraigcool. am playing around with incanter while i find my away around some bayesian inference stuff. was very happy to find it. thanks !
14:18liebkeyou're welcome, I hope you find it useful
14:55wwmorgan(= (float 0.5) (double 0.5)) returns true, but (= (float 0.55) (double 0.55)) returns false
14:57Licenser_wwmorgan: I am pretty sure that this is related with the way float and double rounds
14:58hiredman,(float 0.5)
14:58clojurebot0.5
14:58hiredman,(float 0.55)
14:58clojurebot0.55
14:58hiredman,(double 0.55)
14:58clojurebot0.55
15:00Chouser,(== (float 0.55) (double 0.55))
15:00clojurebotfalse
15:00Chouser,(== (Float 0.55) (Double 0.55))
15:01clojurebotjava.lang.RuntimeException: java.lang.Exception: Expecting var, but Float is mapped to class java.lang.Float
15:01Chouser,(== (Float. 0.55) (Double. 0.55))
15:01clojurebotfalse
15:01Chouserthat seems rather unfortunate
15:02durka42,(.floatToIntBits (float 0.55))
15:02clojurebotjava.lang.IllegalArgumentException: No matching field found: floatToIntBits for class java.lang.Float
15:02stuartsierra,(= (Float. 0.55) (Double. 0.55))
15:02clojurebotfalse
15:02durka42,(.floatToIntBits (Float 0.55))
15:02clojurebotjava.lang.RuntimeException: java.lang.Exception: Expecting var, but Float is mapped to class java.lang.Float
15:02durka42bah
15:02durka42,(.floatToIntBits (Float. 0.55))
15:02clojurebotjava.lang.IllegalArgumentException: No matching field found: floatToIntBits for class java.lang.Float
15:03hiredmanevery day for about an hour #scala turns into ".equals sucks, what can be done to fix it, omg the cure is worse then the disease"
15:03durka42but, but
15:03durka42it's right here http://www.j2ee.me/j2se/1.4.2/docs/api/java/lang/Float.html#floatToIntBits(float)
15:03Chouser,(Float/floatToIntBits 0.55)
15:03clojurebot1057803469
15:03durka42oh, duh
15:03durka42,(Double/doubleToLongBits 0.55)
15:03clojurebot4603129179135383962
15:03wwmorgan,(.doubleValue (float 0.55))
15:03clojurebot0.550000011920929
15:03stuartsierrathere's your answer
15:04wwmorganany suggestions?
15:04durka42use an epsilon to compare floating point numbers
15:04Chouserstuartsierra: ah, of course. don't attempt to use equality with floating point
15:04Chouser,(== 5 5M)
15:04clojurebottrue
15:05stuartsierra,(< (Math/abs (- (float 0.55) (double 0.55))) 0.001)
15:05clojurebottrue
15:05wwmorganthat's OK, but I'm actually trying to compare two nested structures
15:05wwmorganI may be able to work around it in the way that I construct them, however
15:06wwmorganby explicitly specifying number type
15:06stuartsierraIf you care about equality, you should probably use BigDecimal
15:06durka42you still can't rely on equality between to Floats
15:06durka42two*
15:06durka42(== 0.2 (+ 0.1 0.1))
15:06durka42,(== 0.2 (+ 0.1 0.1))
15:06clojurebottrue
15:06wwmorganah. Good points
15:08durka42,(apply + (take 10 (repeat 0.1)))
15:08clojurebot0.9999999999999999
15:30hiredmanhttp://twitter.com/nicksieger/status/4064269448 seems like an interesting idea
15:30hiredmanturn events into a lazy sequence
15:40Chouserlazy-xml does essentially that -- turns SAX parse event callbacks into a lazy seq of event objects
15:43Chouserwith plenty of painful thread management inside. :-/
15:44hiredmanorly
15:44tomojis DnD not what I think it is?
15:44hiredmandrag and drop
15:44tomojaah, heh
15:50manic12with jswat, I can set a breakpoint, but once I get there I can't do anything at all except stop the debugger. after stopping the debugger, it refuses to reconnect to process
15:50Chouseroh, in fact I split that out. seq-utils/fill-queue packages up the ugliness and can act as a general facility for turning async events into a lazy seq
15:50Chousermanic12: you can't look at the stack trace or anything?
15:50Chouser(before stopping the debugger)
15:51manic12yes, I can look at the stack trace, but it wont let me resume from the breakpoint or even step forward
16:01LauJensenRich uses this phrase in his essay on state and identify " It causes a bifurcation of the program protocols" - What does it mean ?
16:04Chouserwhen you want to represent an action, should you do so using a message or a function?
16:05ChouserWith clojure agents, the action is always a function -- there is no "message".
16:10technomancytomoj: you were thinking dungeons 'n' dragons too? =)
16:10hiredman2d6+11
16:10clojurebot14
16:10savanniwow
16:10hiredmanwhat a crummy roll
16:30technomancy(try (eval '(throw (InterruptedException.))) (catch InterruptedException _ nil))
16:30technomancy^ this doesn't catch the exception
16:30technomancyany idea what's going on there?
16:30technomancyworks fine w/o the eval
16:31Chousuketechnomancy: maybe eval wraps it in a RuntimeException?
16:32technomancyI get: No message. [Thrown class java.lang.InterruptedException]
16:32tomojtechnomancy: yup
16:32technomancynot a nested exception
16:34ordnungswidrig1hi
16:34ordnungswidrig1compojure-test> (contains? ::a ::a)
16:34ordnungswidrig1false
16:34ordnungswidrig1compojure-test> (contains? [::a] ::a)
16:34ordnungswidrig1false
16:34ordnungswidrig1That confused me
16:35Chousukecontains? is a key test actually
16:35Chousuke(contains? [::a] 0)
16:35Chousuke,(contains? [::a] 0)
16:35clojurebottrue
16:35Chousuke,(contains? [::a] 1)
16:35clojurebotfalse
16:36ChousukeI think it's rather badly named :P
16:36ordnungswidrig1Chousuke: uhm, very baldy.
16:36ordnungswidrig1I thought it was a "sequence containmend test"
16:37ChousukeI suppose most people think that. but it's not :)
16:37ordnungswidrig1So, which functions tests for containment?
16:38stuartsierrain a sequence, they don't
16:38stuartsierrayou generally use sets
16:39stuartsierra,(some #{1} [:a :b :c])
16:39clojurebotnil
16:39ordnungswidrig1stuartsierra: yes, ok. I read to use some. Sth. like (some #{:a} [:a :b :c])
16:39ordnungswidrig1,(some #{:a} [:a :b :c])
16:39clojurebot:a
16:39ordnungswidrig1ah!
16:40stuartsierrac.c.seq-utils/includes? does the same thing
16:40ordnungswidrig1contrib?
16:40stuartsierrayes, clojure.contrib.seq-utils
16:45LauJensenRich uses this phrase in his essay on state and identify " It causes a bifurcation of the program protocols" - What does it mean ?
16:48hiredmanLauJensen: scrollback, start reading after the first time you asked
16:48LauJensenYou mean Chousers comment?
16:49hiredmanyes
16:49LauJensenAh, I wasn't sure it was for me, thanks
16:49hiredmanit's also a good idea to include some more context in questions
16:50hiredmanthat line was specifically about actor style message passing as a concurrency construct
16:50ordnungswidrig1LauJensen: you mean the term "bifurcation" or the complete phrase makes no sense?
16:50LauJensenIts 'bifurcation' that's tripping me up
16:50manic12bifurcation means to split
16:50LauJensenOh ok
16:50ordnungswidrig1LauJensen: It's a term used in chaos theory
16:51manic12to split a path or stream or something like that
16:51ordnungswidrig1LauJensen: Think "diversion"
16:52LauJensenOk, so he's basically saying that you have to work around the programs own protocols ?
16:53ordnungswidrig1LauJensen: http://en.wikipedia.org/wiki/Bifurcation_theory The second image is a popular example of a function that -- for certain values begins to switch between multiple values -- it bifurcates.
16:53manic12maybe he's saying that there shouldn't be two or more ways of doing exactly the same thing
16:53ordnungswidrig1LauJensen: Can you give me a pointer to the essay. I did not bookmark it
16:53LauJensensure, http://clojure.org/state
16:54manic12of course i am reading your question with almost zero context
16:55hiredmanyou could just ask him when he is around
16:55ordnungswidrig1LauJensen: he says the program protocol is split into parts: some part of the protocol is the functions and some part is the value passed
16:56ordnungswidrig1LauJensen: do you know actor based concurrency?
16:56LauJensenah ok
16:56LauJensenYea I have the general idea
16:57ordnungswidrig1LauJensen: To make concurrency work with actors you must get the messages right that are passed and you must get the functions right that work on the messages. I think this is what he means by bifurcation.
16:57ordnungswidrig1LauJensen: message+functions
16:58LauJensenSeems plausible, thanks for helping me decrypt it
16:58manic12in other words the logic of the program is divided into two areas, eh?
17:00manic12i figured out my stupidity with this damn swat, it was stopping all threads instead of just the one I wanted it to stop
17:02ordnungswidrig1manic12: yes, two areas, if you like
17:03ordnungswidrig1anybody using compojure?
17:07manic12it's both good and bad that rich has taken a pragmatic approach towards choosing a platform for his language design
17:08manic12it's good that the jvm is popular, and that clojure integrates well with java
17:12Makoryumanic12: Hmm, what happened to the projects to get Clojure running on other VMs?
17:13Chousukenothing. :)
17:13manic12i know very little about that and choose to stick my head in the sand on that matter
17:13ChousukeClojureCLR still exists.
17:13MakoryuHow's it doing?
17:13Chousukethat I don't know
17:13manic12does it use the DLR?
17:14technomancysome people have reported that it's "4 weeks behind regular Clojure", but I don't know where that comes from.
17:14Chousukehttp://github.com/richhickey/clojure-clr
17:14technomancyI haven't seen any commits for it in contrib in ages.
17:14technomancyoh, did they spin it off into its own project?
17:14technomancywhy is rich hosting it?
17:14ChousukeIt's semi-official I think
17:14manic12how about a clojure on a lisp runtime?
17:15Makoryumanic12: Define "a lisp runtine." I'm curious :p
17:15MakoryuYou mean compiling Clojure to portable Common Lisp?
17:15ffaillais there a way to define a function literal without an an argument
17:15technomancymanic12: you mean Common Lisp? would be easier to write once clojure-in-clojure is finished
17:15Chousukeffailla: #(foo bar)?
17:15manic12(I'm just joking because it would probably work as well as scheme does on a symbolics machine)
17:16technomancyminor pet peeve: people calling Common Lisp "lisp"
17:17Makoryutechnomancy: Yeah. Clojure and Scheme are every bit as worthy of the name
17:17manic12'splain
17:17MakoryuHell, so's Arc
17:17manic12clojure is not lisp
17:17stuartsierraClojure is *a* lisp.
17:17Makoryumanic12: Common Lisp is not the original Lisp.
17:17ffaillaChousuke: yes, why wouldn't this work (let [f #(+ 1)] (f 1234))
17:17manic12clojure is a clojure and has left lisp to the history books
17:17Makoryumanic12: Okay, now you've veered off into tinfoil hat territory
17:18manic12how so?
17:18Chousukeffailla: because you're calling f with an argument and it doesn't take any :/
17:18manic12I've been programming Lisp (CL) for years and clojure is nothing like CL or even scheme really
17:19ffaillaChousuke: duh... thank you :)
17:19Makoryuffailla: You want (fn [& r] (do stuff that ignores r))
17:19Chousukeor possibly
17:19Chousuke,((partial + 5) 10)
17:19clojurebot15
17:19Makoryumanic12: Once more, CL is not the original Lisp.
17:19Makoryumanic12: It's not even older than Scheme.
17:20manic12i didn't say it was
17:20Makoryumanic12: Calling CL "Lisp" is a giant misnomer. Clojure is every bit as much a Lisp as CL is.
17:20manic12what i am saying is that clojure is a departure from lisp
17:20clojurebotclojure is far closer to perfection then python
17:20Makoryumanic12: It really isn't
17:20Chousukeclojurebot: than :(
17:20clojurebotI don't understand.
17:21lpetitis clojurebot's source code available ?
17:21Chousukeyes
17:21Chousukeclojurebot: source
17:21clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
17:22Makoryumanic12: If you disagree, please explain, because I don't see how adding a bit of syntax for literals (something you can do within CL as well) suddenly disqualifies it as a Lisp when all its other attributes are very much in the tradition of Lisp.
17:22lpetitomniscient clojurebot, soon it will automatically change it's own source code in git, recompile himself, maybe also create sibling bots to have conversations with when everybody's sleeping :)
17:22Makoryumanic12: By the way, Clojure is far from the first Lisp to be implemented on the JVM
17:22manic12i think that clojure is it's own new thing
17:23LauJensenlpetit: Yea I was wondering about that (ns com.skynet.clojurebot) in the source
17:23manic12it focuses on sequences abstractly and not cons cells
17:23Makoryumanic12: And CL has a huge pile of generic functions that do exactly the same thing.
17:24manic12CL was pushing the limit of what it means to be a lisp too
17:24MakoryuSo why do you insist on calling CL "Lisp" (not "a Lisp")?
17:24Chousukethis argument is silly
17:25ChouserChousuke: +1
17:25lpetitI was searching a way to go to sleep, please continue this very interesting existential conversation a little more, it'll get me to sleep quicker than I had expected :-p
17:25lpetitwould have
17:25manic12what I am saying is that at some point you have to make a break in calling a language a Lisp when it draws from so many other influences
17:25tomojwhat counts as a lisp, really? anything with code as data?
17:25tomojare sexp's important?
17:26tomojor is it a genealogical thing?
17:26LauJensenLet me settle this for your boys, I asked google "define: lisp", and this is the truth: a speech defect that involves pronouncing `s' like voiceless `th' and `z' like voiced `th'
17:27LauJensenOr from Wikipedia/Lisp: "There are also a few new dialects of Lisp. Notably: Newlisp (a scripting language), Arc (developed by Paul Graham) and recently Clojure (developed by Rich Hickey) and Nu for programming with Apple's Cocoa."
17:27manic12clojure is not a lisp
17:27Makoryumanic12: Then neither is CL or Scheme ;)
17:27Chouser,(cons 1 (list 2 3))
17:27clojurebot(1 2 3)
17:28lpetitfrom the creator of Qi in ( http://www.lambdassociates.org/blog/nextlisp(1).htm ) :
17:28manic12clojure has things in common with languages that are modern versions of lisp 1.5, but at some point there is a difference
17:28lpetitIf we ask ourselves, ‘What is the genotype of Lisp?’, what is its DNA, its genetic legacy, I'd suggest that it is composed of the following five ideas. 1. Recursion as the primary mean of expressing procedure calling. 2. Heterogenous lists as the way of composing and dissecting complex data. 3. Programming by defining functions. 4. Garbage collection. 5. Programs as data.
17:28lpetitinteresting distinction between the genotype and the phenotype of lisps.
17:29ChouserClojure easily fits all those except perhaps 2
17:29Chousukelists are only replaced with the more generic "sequences" :P
17:30lpetityes
17:30manic12so only #5 seperates it from .net or anything else
17:30Chouseror seqs, vectors, and maps.
17:30lpetitand Qi will be ported to clojure to be hosted on the JVM. So Clojure has been seen as having the same DNA as Qi :)
17:30ChouserI rarely "compose complex data" with seqs, though I frequently use them for dissecting
17:31MakoryuI'd add something to the list above: Every Lisp should support a usable superset of its feature influences.
17:31MakoryuAnd Clojure does that pretty well, I'd say
17:32ChouserI find it handy to refer to clojure as a lisp, because it seems to be meaningful in an accurate way to a lot of people.
17:32lpetitBut really guys, isn't that just the difference between the stages of a same program, made easy in lisp, maybe not so easy in other languages ?
17:32Chouserthough ultimately I don't care much if it actually is a lisp
17:32manic12ok, so it's "handy"
17:32manic12neither do i
17:32Chouserhooray!
17:32lpetitI mean : iterative programming, start with simple data structures, and maybe enhance them
17:33lpetitEven in common lisp they do so I guess. CLOS is certainly used in practice !
17:34Makoryumanic12: You seem to care a lot, what with the number of times you've insisted in the past few minutes that Clojure is not a Lisp...
17:34lpetitbye guys, cu
17:35LauJensennight night
17:35Chouserlpetit: ciao
17:35lpetitWhat time is it in Denmark ?
17:35lpetit:)
17:37MakoryuChouser: SURE! How about SCALA?!?
17:37Makoryu:D :D :D
17:37Chouserheh
17:37LauJensenChouser: haha :) I've run out of languages
17:38Chouserreally? no C++?
17:38Chouseryou could go kick the groovy guys around a bit
17:38LauJensen(filter #(must-not-be-cruel-comparison %) available-languages)
17:38MakoryuDidn't they actually surrender to the Scala folks, or something?
17:39ChousukeLauJensen: redundant use of #()
17:39manic12Lisp originally stood for List processing, clojure is to lisp processing as jet engines are to propellors
17:39LauJensenI think if I was to write up another Vs piece, it had to bring something to the table which was not obvious... I can't think of anything atm
17:40manic12list processing
17:40Chousukemanic12: the word lisp has since changed its meaning.
17:41LauJensenChousuke: yes, Lisp actually means Clojure nowadays
17:41Chousuke:)
17:41LauJensenlittle known fact...
17:41Chousermanic12: would you buy "like a lisp"?
17:42Chousermanic12: what about "looks like a lisp"?
17:42manic12i'm just stating my opinion
17:42crios,(filter #(= "remove" %) (keys (ns-publics 'clojure.core)))
17:43clojurebot()
17:43Chousermanic12: I'm asking for your opinion
17:43crioshow can I extract the function with name "remove"?
17:43manic12oh
17:43Chouser,(filter #(= 'remove %) (keys (ns-publics 'clojure.core)))
17:43clojurebot(remove)
17:43manic12it "looks like a lisp"
17:44Chousermanic12: but isn't "like a lisp"?
17:44manic12because the parens come before the function, and it is like a lisp in that code is data
17:44criosthank you Chouser (forgetting the symbol!)
17:44manic12but the v22 takes off like a helicopter and flys like a turboprop
17:44Chouser,(filter '#{remove} (keys (ns-publics 'clojure.core)))
17:44clojurebot(remove)
17:44ChousukeI think any language that has a homoiconic representation based on lists or list-like things could be called a lisp
17:46Chouser,('remove (-> 'clojure.core ns-publics keys set))
17:46clojurebotremove
17:46Chouserha!
17:46Chouser,(-> 'clojure.core ns-publics keys set 'remove)
17:46clojurebot(clojure.core/-> (clojure.core/-> (clojure.core/-> (quote clojure.core) ns-publics) keys) set)
17:47Makoryu,(doc ->)
17:47clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
17:47Chousuke.. something funky happened with -> there
17:48ChouserChousuke: yeah, the ' at the end was expanded at read time, before -> got a chance
17:48Chouserso then the whole thing got stuck inside a (quote ...)
17:48Chousukeheh
17:48Chouser,,(quote lots-of-stuff remove)
17:48clojurebotlots-of-stuff
17:49criosmm I prefere (filter '#{remove} (keys (ns-publics 'clojure.core)))
17:49criosprefer
17:49Chousercrios: that's probably an appropriate preference. :-)
17:50crioswell, much more readable, just IMHO of course
17:51hamzahey guys, is it possible to create an interface from clojure? (not implement)
17:51Chouserhamza: yes, but it must be AOT-compiled
17:51Chouserhamza: (doc gen-interface)
17:52Chouser,(-> 'clojure.core ns-publics keys ((partial filter '#{remove})))
17:52clojurebot(remove)
17:54hamzaChouser: does that kill the ability to test code using repl since i have to compile all the time?
17:54hamzadoc says it does nothing when not compiling..
17:54Chouserhamza: only compile the interface when the interface changes
17:55Chouserso get it right. :-) creating new implementations with proxy can be done at runtime.
17:55Chouserhamza: it is a restriction, but one that comes from the JVM.
17:56Chouserdinner time. later, folks.
17:56criosChouser here '#{remove} are you "escaping" a set?
17:56hamzakk now i get it :) as long as i keep the .class file on the class path i can play with the interface..
17:57Chousercrios: yes
17:57Chouserno.
17:57Chousercrios: quoting, not escaping
17:58criosok
18:00criosso that quoted set is the predicate of filter. It applies that predicate to all elements inside the (keys. When matching, the return value is true
18:00crioscorrect?
18:02criosI mean when using this expression: (filter '#{remove} (keys (ns-publics 'clojure.core)))
18:03hamza,(+ 1 2)
18:03clojurebot3
18:08ambientgroovy surrendered to scala? (reading the backlog ~1hr)
18:09ambienti've read through at least 10 different emacs tutorials and i know all those commands very well, but still feel like im just scratching the surface
18:10ambienti wish there were different what-i-use-for-my-stuff reports from people who have used emacs for lisp programming for a long time
18:10technomancyambient: not to toot my own horn, but the PeepCode screencast on Emacs does that.
18:10technomancyas does the Starter Kit: http://github.com/technomancy/emacs-starter-kit
18:10ambientcool, i shall check that out
18:10technomancyhave you seen http://technomancy.us/126 ? for clojure-specific functionality.
18:11technomancyambient: nothing compares to pairing with a pro though.
18:11ambienti tried using the started kit but didn't enjoy some of its defaults and didn't really see the point in using it, because clojure-install already does all that i need (that I'm aware of..)
18:12technomancythere's http://planet.emacsen.org too
18:12ambientbookmarked :)
18:14ambienti wonder if there's any kind of an integration for firefox and emacs, like vimperator does
18:14ambientbut then again, vimperator is so nice that perhaps it's not necessary
18:14technomancyambient: heh. vimperator was inspired by conkeror, which is exactly that.
18:14ambientonly thing i hate about vimperator is that i can't live without it anymore :(
18:15ambientseems that conkeror is not a firefox addon
18:16technomancyit's a separate app
19:00hiredmanI think an IAgent needs to be lifted out of Agent
19:02hiredmanthe interface for interacting with the EDT via invokeLater is almost exactly what you get from an agent, so I'd like to be able to implemented an IAgent interface on top of it
19:12hiredmanclojure.lang.Agent$Action being protected is kind of a drag
19:14hiredmanit would be nice if there was an IAction interface that was public at least
20:10Kjellskihi there =)
20:10rhickeyKjellski: hey
20:10Kjellskican someone give me a hint about the make-array function?
20:11dnolen,(make-array Float/TYPE 10)
20:11clojurebot#<float[] [F@215bee>
20:11dnolenKjellski: ^
20:12hiredmanhttp://gist.github.com/192389 <-- actually, I needed Agent$Action to be lifted out into AAction (and IAction) and then replace the "new Action(..." in Agent with a new method called getAction
20:12KjellskiActually I´m in some sort of newbe trouble I think. So what I´m trying to do is to make an array over an array of "things" and I´ve tried this:
20:12hiredmanfaux-agent should interact with the STM the same way agents do
20:13Kjellski(def test (seq (make-array Integer 2 2))) which should give me a 2by2 "matrix" of ints right?
20:13MakoryuKjellski: Interesting smart-quotes... ಠ_ಠ
20:13hiredman(prn :foo) could be replaced with a call to invokeLater or invokeAndWait
20:14hiredmanKjellski: erm
20:14hiredmanis there a reason you are using arrays?
20:15hiredmanfirst, java doesn't have multidiemensional arrays, it has arrays of arrays, and that is what (make-array Interger 2 2) will make
20:15KjellskiWhat I wanted to do is some sort of minesweeper ... and I thought this would fit the problem ^^ please tell me thr right choise though
20:15hiredmansecond, Integer and int are different types
20:15dnolenKjellski: might be better to just use vectors.
20:15hiredmanints are primitives and Integers are ints wrapped in an Object
20:16Kjellski@hiredman: I know both of these hints, but that doesn´t solve my problem... ^^
20:16hiredmanthird, call seq on the output of make-array is silly
20:16dnolen,[[1 0] [0 1]]
20:16clojurebot[[1 0] [0 1]]
20:16technomancyKjellski: arrays are for java interop.
20:16hiredmanseq returns a sequence
20:16hiredmanhas anyone heard anything about an electronic version of the contrib agreement?
20:17KjellskiOkay, sorry... maybe a bit closer to my real example, I want to stuff JButtons in there... ^^
20:17technomancyhiredman: there's a company here in Seattle that was talking about implementing that for a different OSS project
20:17technomancyhad their lawyers look it over; said it would hold water
20:17hiredmanKjellski: definitely don't use arrays
20:17KjellskiBut however, this will give me a nil seq...
20:19dnolen,(get-in [[(Object.) (Object.)] [(Object.) (Object.)]] [1 1])
20:19clojurebot#<Object java.lang.Object@18b1699>
20:20Kjellskihiredman: what is the better choice?
20:21hiredmanwell nuts, I don't have any envelopes
20:21hiredmanKjellski: a vector
20:21hiredmanwoa
20:23hiredman,(let [board [[nil nil nil] [nil nil nil] [nil nil nil]] move [1 1]] (update-in board move (constantly 'x)))
20:23clojurebot[[nil nil nil] [nil x nil] [nil nil nil]]
20:23hiredman:D
20:28enderoute(defstruct foo :x :y :z) (def bar '(3 4 5)); how can I struct a foo with bar? its got to be something simple
20:28hiredman(apply struct foo bar)
20:29enderoutethanks
20:47khoracould you give me a clojure example to compile?
20:53hiredmanI think wrapping SwingUtilities/invokeLater in the Agent abstraction might be the coolest thing since sliced bread
20:53hiredman~compile
20:53clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
20:54hiredmanthere is an example there
21:53dysingerAre queues worked in yet?
21:53dysingerWe are coding some message pub/sub in 1.1
21:54rhickeydysinger: you want to use JMS?
21:56dysingerWe are trying to abstract. We are using activemq & rabbitmq
21:56dysingerTo start
21:57dysinger(pub / sub / broadcast )
21:57rhickeythe problem with abstracting is that key features get left out
21:57dysingerY
21:58dysingerIt's ok - was just curious
21:58rhickeyI started to design something to wrap both j.u.c. queues and jms and found too many differences to make it worthwhile
21:58dysingerI hear you
21:59rhickeynow I'm hoping HornetQ or ActiveMQ in local mode are fast enough to provide an in-memory-through-distributed API
21:59rhickeybut AMQP is a whole other thing
21:59dysingerWe can abstract over a couple I think
21:59dysingerFor our needs
22:00dysinger(basic)
22:01rhickeyI've decided not to put it on my plate for 1.1, so maybe you could run with it and contrib something
22:01rhickeythe ideas I've been fiddling with are: tying queue transactions to dosync
22:02rhickeyqueue versions of map and filter
22:02dysingerrhickey: Thanks again btw :) our clojure team would be doing something else less cool without your hard work :)
22:03rhickeyyou're welcome
22:03dysingerWe are now pairing over screen/emacs/voip :)
22:03dysingerSo fun.....
22:04rhickeygotta run
22:04dysingerL8r
22:55hiredmanlisppaste8: url?
22:55lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:56lisppaste8hiredman pasted "hydra (producer/consumers)" at http://paste.lisp.org/display/87611
23:07lisppaste8hiredman annotated #87611 "better docstring? returns lazy-seq instead of LBQ" at http://paste.lisp.org/display/87611#1
23:19duck11231would it be worth it to have some sort of manifest file that could be placed inside jar files to describe what clojure namespaces are contained within?
23:38mabeshow do I look up a function if I have the name in string form?
23:38hiredman,(-> "+" symbol resolve)
23:38clojurebot#'clojure.core/+
23:38hiredman,(-> "+" symbol resolve deref)
23:38clojurebot#<core$_PLUS___4094 clojure.core$_PLUS___4094@4e0456>
23:38hiredmanthe first one gets you the var, the second the function inside the var
23:39mabes,(apply (-> "+" symbol resolve) '(1 2 3))
23:39clojurebot6
23:39mabesthanks hiredman and clojurebot!