#clojure logs

2008-12-30

00:20knabbi figured it out
00:20knabbamazing you have to use xml for the buildsystem
00:42knabbhmm i m thinking
00:42knabbwhen implementing a stack in clojure
00:42knabbpush could just cons to a list
00:42knabbbut pop
00:43knabbshould it then return the first element of that list and the rest of the list?
00:43knabba stack seems naturally represented with state
00:43knabbso a macro to redef the passed variable
00:44vogelrnthere's already peek that returns the head and pop that returns the rest
00:46knabbyes but pop should do both i mean
00:47vogelrnwell the point is that it doesn't when you're thinking functionally
00:48vogelrninstead, you would likely use the head and recurse on the rest, or something of that nature
01:06knabbjava really is the greatest eample of really poor problem solving
01:06chrisnIs there an error function (like failwith or fail in other languages)?
01:06knabbsolve a problem by fixing it with an even more complex and idiotic problem
01:07chrisnnm, found them in contrib
01:07vogelrnknabb: What are you referring to out of curiosity?
01:11knabbant
01:12knabbxml
01:12iamslashI'm a newbie of clojure... using emacs slime... can evaluate expressions... but
01:12iamslashslime-edit-definition doesn't work.. on emacs...
01:12iamslashwhat can i start from..?
01:12knabbwhat is the name of the symbol that looks like a weird E and is used a lot in math notation
01:13vogelrnyou mean the sum one?
01:13knabbiamslash: if you use windows try clojure-box, otherways clojure-mode for emacs is easy to install.
01:13iamslashI'm using clojure-mode...
01:14knabbnot lisp-mode?
01:20iamslashI installed... git://github.com/jochu/clojure-mode.git git://github.com/jochu/swank-clojure.git
01:21iamslashclojure expressions work well... but when I run 'slime-edit-definition'
01:22iamslashEmacs debunk "source definition not found' message...
01:22vogelrnto be honest I don't actually know what that is, I don't know much about emacs aside from the various tutorials I've read. What are you trying to do?
01:22vogelrnslime-edit-definition, that is
01:22iamslashyeah right...
01:26iamslashhttp://groups.google.com/group/clojure/browse_thread/thread/e0ece17449ab24ec/5decf3d10d69616f?lnk=gst&q=%22Source+definition+not+found%22#5decf3d10d69616f
02:45Lau_of_DKGoood morning gentlemen
02:48drewrGood morning.
02:49Lau_of_DKRough night? :)
02:50drewrFever, sore throat. Doesn't look good... :-)
02:51Lau_of_DKIt sure doesnt, although I know many people having a hard time with that these days
02:53drewrFortunately germs don't travel well over IRC.
02:53Lau_of_DKScientists may disagree on that
10:19jgracinjust updated SLIME and swank-clojure and now I'm getting an error during startup. (wrong-type-argument sequencep t)
10:19jgracinI guess those are related to slime-repl changes. Has anyone managed to fix it?
10:20jgracinOr perhaps, does anyone else have this problem?
10:21akingjgracin: for a working slime, I had to rollback my git slime to dec23
10:22jgracinaking: I see. Thanks, I'll do that.
10:33Lau_of_DKGood afternoon gentlemen
10:33danlarkinmornin'
10:33Chousukeevening
10:34Lau_of_DKYou guys are either confused, or your nations have not yet been assimiliated by the Empire of Denmark
10:35karmazillaMy suggestion to allow an alternative doc-string placement have not spured much discusion. I wonder if people are happy with the current allowed syntax
10:35Lau_of_DKkarmazilla: What was your suggestion?
10:36karmazillato allow the doc-string to come after the [params*]
10:36Chousukekarmazilla: wouldn't that create ambiquity?
10:37danlarkinbut isn't that ambiguous?
10:37Lau_of_DKkarmazilla: that would be ambiguous
10:37Lau_of_DK:)
10:37Chousukewhat if you wanted a function like (defn foo [] "string")
10:37karmazillano, I defined it in a way that limited it to unambigues usages: http://groups.google.com/group/clojure/browse_thread/thread/fcde7a631a033b7b/faf1a89ab490f582
10:37Lau_of_DKBut karmazilla, I agree that where it is now, is not very nice, Ive thought about an modification myself
10:38karmazillaChousuke: that should work as it does today'
10:39danlarkinI like where the docstrings are now
10:39ChousukeI think the docstring is just fine between the symbol and the parameters
10:39karmazillabut (defn foo [] "spam" "string") is already allowed syntax, but the "spam" part isn't used for anything
10:40Lau_of_DKkarmazilla: Is the only advantage of this change prettier code?
10:40danlarkinkarmazilla: but (defn foo [] (println "side effect!!") "string") is allowed too, same thing as (defn foo [] "spam" "string")
10:40karmazillaLau_of_DK: yes, just prettier code
10:41Lau_of_DKok
10:41karmazilladanlucraft: not the same thing... side-effecting thingy != no-op string
10:41Lau_of_DKIsnt there already an option of doing something like (defn #^{:doc "This does nothing"} myfunc [x y] nil) ?
10:43danlarkinkarmazilla: well what I mean is that "spam" in that example isn't a no-op string... it's a form in an implicit do
10:43danlarkinit gets evaluated
10:44ChouserI think karmazilla is correct that his proposed format wouldn't break anything.
10:45karmazillaI don't have the fantasy to imagine a cenario where it would break, anyway
10:45ChouserBut personally I don't think it matters much -- one more optional way to format defn, slightly more complex implementation and docs, very minor (or no) benefit.
10:46Chousergenerally, I'm either writing one-off functions and provide no doc string at all and only one body per function. Or I'm trying to write good clean maintainable functions, and I provide doc strings and am much more likely to provide multiple arities.
10:48Chouserkarmazilla: not to be discouraging, but that's why I've not weighed in on the g.group.
10:49danlarkinI'd prefer the possibility for """this style string""" more than this change :)
10:50rhickeykarmazilla: I'm not interested in supporting that syntax as it adds little and doesn't scale to multiple arities
10:51rhickeyobviously it was considered and rejected
10:51karmazillaMaybe it's just a habit that have this bother me more than most. When I write library code, I try to be rather thorough with my doc-strings, putting in code examples and other stuff, and then it just.... would feel better if I could put the arg list on top
10:51rhickeyI have pages and pages of variants of fn in my initial design docs
10:51karmazillaok
10:51rhickeydesign is about tradeoffs - multiple arities won here
10:53Lau_of_DKkarmazilla: I think it was cool that you actually went the extra-mile and provided a patch though, I hope you keep the creativity flowing :)
10:53duck1123_It takes a while to get used to (coming from other lisps) but once you see the reason for why it is, it's not that bad.
10:55karmazillaI guess I have to keep my python out of my clojure, like I have to keep my haskell out of my python, and my java out of... no, wait.. nothing
10:56Lau_of_DK:)
10:56Lau_of_DKI agree, keep Python away
10:57duck1123_keep the peanut butter and the chocolate together though
10:57Lau_of_DKWise words
11:12StartsWithKdoes anyone know can clojure now be used with osgi? if not, maybe example of using ServiceLoader, it looks like ServiceLoader uses one class loadef for all bundles, so maybe that could work for clojure
11:13StartsWithKi looked at cloujredev, eclipse plugins are osgi bundles, but it is in java nad clojure is not separate bundle, and there is no interaction from clojure code with object from other bundles
11:13StartsWithKclojuredev*
11:14duck1123_forgive me if I'm wrong, but isn't OSGI kinda like a servlet container?
11:16StartsWithKsomething like that
11:17duck1123_I know clojure works with Tomcat, so there's hope at least
11:17StartsWithKproblem last time i had is that every bundle gets his own class loader (or somethin even more complicated than that), so i couldn't..
11:17StartsWithK.. create bundle without his private clojure.jar
11:18StartsWithKand even with that, if proxy created with clojre would be sent to some other bunde it would fail, i think it remeber its old class loader
11:19StartsWithKis this resolver maybe after AOT was added
11:20duck1123_you were trying to create classes for a different system with proxy?
11:21StartsWithKif object was created in bundle A, then passed as argument to method on object created in bunlde B, then it would fail
11:22StartsWithKonly 'solution' was that every bundle has everything it needs inside it, but then there was no point in using osgi
11:22duck1123_I would definitely try again post-AOT
11:23StartsWithKso RT changed the way how it handles class loader?
11:24duck1123_I know some things changed in that area... don't know if it solves your problem without looking deeper at it
11:26StartsWithKuf, don't want to go on that experimenting road with osgi like last time.. wasted too much time on it before
11:26StartsWithKthere is also *use-context-classloader*, and it was in clojure before
11:26StartsWithKbut its use is undocumented
11:27StartsWithKit sugest that something could use another proxy, and not the one in RT
11:44Lau_of_DKYo Pupeno
11:47PupenoHello Lau_of_DK.
11:48RaynesI find it amusing that even in the infancy of this language, there is more people in this channel than there is in #Scala.
11:48Raynes:>
11:49Lau_of_DKMuhahaha :)
11:49ChouserFriendlier ones too.
11:49Lau_of_DKAww Chous', was that directed at me? *blush*
11:49ChouserI imagine having the author here increases the relevence of the channel quite a it.
11:49Chouserquite a bit.
11:49cemerickRaynes: definitely a good sign, but don't take irc users as an indication of anything like an indication of broader trends.
11:50cemerickThe masses like the curly braces, regardless of what is found within them...
11:50Raynescemerick: I said nothing about popularity of either language, it's just funny.
11:50ChouserLau_of_DK: take all the credit you'd like. But I was actually uncharitably directing it at others who appeared to intentionally make me feel like an moron while I was trying to make the jump to FP.
11:51Lau_of_DKcemerick: perhaps we should consider replacing all these parentheses with curly braces then
11:51Lau_of_DKehe
11:51Chouserheh
11:51Raynes{+ 2 2}
11:51Lau_of_DK{defn add [x y] {+ x y}}
11:51Lau_of_DKLooks a bit like barbed wire, kinda cool
11:51ChouserI suppose we'd use () for literal maps then?
11:52Lau_of_DKChouser: Really? That sounds awful
11:52cemerickit's sorta rubyish, really. { somefn arg arg }
11:52Lau_of_DKFP is a big enough steak on its own
11:52cemerick=> reader syntax, baby!
11:52Lau_of_DKPerl!
11:53vogelrnI think #[] is open for literal maps, isn't it? :P
11:53vogelrnavoid using the parenthesis altogether
11:54Chouservogelrn: truly evil, my friend.
11:54ericlavigneWe can have <+ x y> and replace the <,> functions with lt,gt.
11:56danm_scala seems strange to me, like they don't need a macro system because any language feature you could ever hope for is either already in the language, or slated for the next release
11:57ericlavigneOr rather...
11:57ericlavigne <
11:57ericlavigne + x y
11:57ericlavigne >
11:57ericlavigne
11:58danm_call by name parameters are an interesting way to avoid the need for macros as well
11:58ericlavigneBecause not giving parentheses/braces their own line is a dead giveaway that you're using Lisp :-P
11:59Lau_of_DKIf we could somehow implement this it would be great: http://99-bottles-of-beer.net/language-perl-737.html
12:01Lau_of_DKhehe, you should see the Malbolge solution then
12:01Lau_of_DKHAHA: http://99-bottles-of-beer.net/language-lolcode-1544.html
12:04Lau_of_DKAnd an extra fact, Clojure is actually on the top10 on that site
12:21mibudoes anyone here know how to use the clojure.parallel lib?
12:25akingWhen inside a proxy function, how can I do a "return this;"?
12:30mibuaking: I think just "this".
12:32akingmibu: thanks - seems to compile - I test in a sec. So, 'this' is a reserved word? I don't see it mentioned on the java interop page.
12:32rhickeyaking: no, 'this is just bound by the proxy macro
12:32mibuaking: it's not reserved. it's just implicitly bound to this
12:33rhickeyhmpf, no java.beans in Android
12:34akingahh.. thanks - rereading the proxy doc mentions it - sorry for the noise.
12:34inertia-rhickey: clojure on the llvm, possible? certainly seems worth it
12:34rhickeyinertia-: with what libraries?
12:35inertia-itself - perforamnce is what i am thinking of
12:35rhickeyinertia-: better to target a fast CL
12:36rhickeyonly perf benefit over JVM is tagged fixnums
12:36rhickeywithout polluting Clojure with primitive types
12:36inertia-isn't there a greater potential for perf increases over time?
12:37inertia-i'm not saying i'm a performance whore but i certainly think about it
12:37rhickeyLLVM is not nearly the same infrastructure as JVM/CLR
12:37inertia-(mainly that java is always 1-4 times worse than C on alioth benchmarks)
12:37rhickeyI'm completely not interested in reinventing wheels
12:37inertia-:)
12:38inertia-i like clj very much, thanks rh
12:38rhickeyinertia-: you're welcome!
12:42zakwilsonI think it would be cool if somebody implemented languages similar to Clojure for other platforms, but Clojure is very clearly tied to the JVM. It took me a long time to come around, but I think that's a Good Thing.
12:43rhickeyzakwilson: Clojure could easily target the CLR, and once did
12:43rhickeycould probably target any OO host with MT primitives
12:44rhickeyor drop MT, as ClojureScript does in targeting Javascript
12:45rhickeyugh, jar utility cannot remove files ?
12:55Chouser(complement neg?) vs. #(not (neg? %)) vs. #(>= % 0) ...opinions?
12:58mibuchouser: not neg if you have a literal style, >= if you're the compact type.
12:59mibuchouser: for me, it's a matter of mood.
13:08rhickeyHello Android World! (from Clojure)
13:08mchurchWhat is the best/preferred way to spawn a thread in Clojure?
13:10karmazillamchurch: if not with an agant, then maybe (doto (Thread. #(println "pokemon")) .start) ?
13:15mchurchkarmazilla: I haven't gotten to agents yet in my reading, but they sound cool.
13:15mchurchkarmazilla: I'm just looking for very basic thread functionality now (prototyping something) so that will probably be enough.
13:17rhickeydanlarkin: looks like bean is the only function that uses an unsupported API (java.beans)
13:19rhickeyI'll check in as soon as I figure out how to handle bean (had to comment it out to get Hello Android to run)
13:19akingcool - will try it as soon as it's in
13:19akingrhickey: what did you do for the classloader? That patch I submitted - or a proper fix?
13:20rhickeyaking: a proper fix :)
13:20akingheh :)
13:20rhickeythe problem with the patch is it ignores the fact that the classloaders should have delegated
13:21rhickeyrather than just workaround, I dug into it and found how Android was responding to contextLoaders etc
13:21rhickeyso now the baseloader is properly rooted on Android and delegation works
13:22akingaye - thought that should have been the case, but I'm not familar enough with how clojure handles the classloaders - but hope it at least pointed at what was wrong
13:22rhickeyalso got the bridge method resolution fixed up, plus special handling for the source being present but the .class not
13:24akingonce you make an announcement on the list, it'll be time to progit/digg it - it's been a few days since there's been a clojure story
13:27rhickeyaking: I'd rather it worked smoothly before it got a lot of attention
13:27rhickeybut support is up (svn 1192) - you'll have to comment out bean in core_proxy.clj manually if targeting Android, for now
13:28rhickeyhave fun!
13:32akingrhickey: great! I'll update and try it out after lunch
13:36Nafairhickey: You got it working?
13:36rhickeyFYI, what I got running was this: http://github.com/Nafai77/helloandroid/tree/master, with no changes to it other than adding <arg value="-JXmx1024M" /> to the dex target in build.xml since I was getting out of mem errors there
13:36NafaiSweet!
13:37rhickeyNafai: you'll need to comment out bean in core_proxy.clj before building Clojure
13:38NafaiJust the bean method?
13:44Nafairhickey: The bean method?
13:46rhickeythe entire bean function in core_proxy.clj
13:46rhickeyno bean on Android
13:46NafaiOk
13:46NafaiRight
13:48replacarhickey (et al.): congrats on getting Android working!
13:53NafaiStill getting a no class def error
13:54akingNafai: I'm updating now...
13:59akingNafai: works for me :)
14:00akingwoohoo - time for some Android clojure coding..
14:00akingdid you copy the updated clojure.jar file to hellowandroid/lib ?
14:00Nafaiaking: Which Android sdk version are you using?
14:00Nafaiaking: Yeah, it's symlinked
14:01akingI'm running it under WinXP - android-sdk-windows-1.0_r2
14:01NafaiI'm on Linux, but same version
14:01NafaiI'll have to play with it later, at work :)
14:02akingNafai: if it's the same class def error, sounds like it's not picking up the updated jar file
14:02NafaiYeah, it does sound that way
14:18Lau_of_DKGood evening Mr. Schulz
14:18akingNafai: got a ddms screen capture of it running if you want to see it. Memory usage isn't to bad - a basic clojure android app seems to take about 2.6Mb
14:19Nafaiaking: Yeah, I'd like to see it :)
14:19Lau_of_DKMe too
14:21AWizzArdclojurebot: max people
14:21clojurebotmax people is 116
14:21akingNafai: see it here: http://antimass.org/aking/clojure-android.png
14:22NafaiYay!
14:24AWizzArdaking: is this running in a Java ME or does your phone support a full JRE?
14:24akingIt's running under Google's Android vm
14:24akingthe emulator - but should work fine on an Android phone
14:25mibu_rhickey: do you plan in the future to implicitly integrate operations from clojure.parallel in the standard operations?
14:26AWizzArdaking: I ask because to my knowledge Clojure currently does not run inside a ME as those guys have too strict memory settings, something like that. So it seems that the Android vm uses some settings that make more sense for todays hardware.
14:27cemerickChouser: did anything concrete come out of the pretty-printer discussion last month?
14:27cemerick(I just want to use one, too :-) )
14:28Chousermibu_: requires a third-party .jar, so it'd surprise me. But there's a pmap in core
14:28akingAWizzArd: I haven't tried under ME - but I don't see why it shouldn't work. rhickey has to remove bean support for android, which I believe ME is also missing, so it might start working.
14:28Chousercemerick: nope, we've got two (unfinished?) implementations.
14:28replacacemerick, Chouser: I was just thinking about digging in on a pretty printer last night
14:28akingAWizzArd: That clojure android app is running Nafai's code here: http://github.com/Nafai77/helloandroid/tree/master
14:29mibu_chouser: I understood the ForkJoin lib will be included in Java7
14:29replacaI'm pretty much done with common lisp format and that leads kind of naturally to the XP pretty printer
14:29Chousermibu_: ah, I didn't know that.
14:29replacaare others doing active work?
14:29Chouserreplaca: I was only working on pprint because I thought nobody else was. I've dropped it for now.
14:30cemerickreplaca: not in this corner. All of my tinkering has fallen by the wayside :-(
14:30ChouserI must say, though, that the CL-style format feels like quite a burden.
14:30replacaI just started reader the MIT tech note on the XP pretty printer last night (the basis of the PP in CL)
14:30replacaChouser: in what sense?
14:31Chouserreplaca: it's like a whole language in itself -- not even an s-expression based one -- and so to use it or read code that uses it I need to learn the parsing rules, functions, the whole works.
14:32cemerickyeah, FORMAT is pretty rough for the user -- mini languages aren't fun
14:32replacaChouser: indeed. it's oonly for those that like it. But it does giive you better control and simplifies your printing code. So it's a trade-off.
14:33cemerickstuff like this scares the bejeezus out of me, for instance: http://cybertiggyr.com/gene/fmt/
14:33ChouserWhen I first started on a pprint, I asked if XP as a good model and rhickey_ said it seemed overly complex. iirc.
14:33replacaThe nice thing about XP is that it's already thought out -> therefore easier to implement
14:34cemerickJava already has a text formatter -- if that can be folded in transparently, then we'll all be better off.
14:34replaca(Cause you don't have to worry about unforeseen corner cases)
14:34Chouserperhaps we could come up with something that has the internal structure and feature set of FORMAT, but uses an s-expr API instead?
14:35replacaOne thing that would be pretty easy is to sexpr the bracket constructs
14:35replacaIt would make it more verbose, but easier to understand the flow
14:36replacaThe nice thing about format is that you don't have to explicitly traverse your structures
14:36replacaThis argument has been going on since the eighties, of course
14:36Chouser:-)
14:37replacaI've always liked format cause it get printing "out of the way"
14:37Chouserbut clojure gives us new tools that CL doesn't have, so it may be worth at least skimming over the argument one more time.
14:37replacaAnd I mostly don't care that the formats are kind of write-only
14:37cemerickreplaca: even when you need to fix a bug?
14:38replacaWell, the bug would only be in the format itself, so you can focus on that. But the point is valid.
14:39replacaI mostly did the format implementation just cause I wanted to (god knows why)
14:39replacaBut there's lots of raw material there to support other mechanisms
14:39replacaand of course we have the java mechanism "built-in"
14:40replacaand certainly one reason to have format "lying around" is that it makes porting CL code easier
14:40replacacause converting the prints seems like a silly way to spend time
14:41replacaall of which is basically orthogonal to pretty printing :-)
14:44AWizzArdcemerick: why are you scared by format? I mean, it's basically a DSL just as regexps are. Or maybe you try to avoid those too?
14:44gnuvinceregexes *should* be avoided when possible :)
14:44Chouserheh. well, I certainly don't mind having a lib around that is 100% backward-compatible with CL for porting. Seems very nice for that use case.
14:45ChouserAWizzArd: I was thinking about that -- if we could come up with an s-expr-based text matching language that was no more than 2 or 3 times as verbose as regex, I'd probably prefer that too.
14:45replacagnuvince: yes, but we don't avoid them when they make our intent clearer.
14:46replacaChouser: yes, but good luck with that. sexprs are pretty verbose relative to these tight string languages
14:46cemerickAWizzArd: format does way, way more than I've never needed such a facility to do. It's too clever for its own good, IMO. regexes solve an immediate and constant problem, and no better option has presented itself, so they remain.
14:46Chouserit might be worth looking at how perl6 approaches regex -- they redesigned to be much better at composition of patterns and such, at some cost in verbosity.
14:47replacaThe advantage of both regex and formats (both CL and Java/printf-style) is that they work in the target domain: strings.
14:48AWizzArdChouser: fair enough
14:48AWizzArdcemerick: well, in todays world it's probably really not too common anymore to print out texts into a shell or something like that. Most programs come with a gui and for those there are other tools.
14:49AWizzArdI don't see it as a real loss to not have format.
14:49gnuvinceformat can return a string which you can put in a message box, label, whatever.
14:50cemerickI'm sure one's opinion is informed by the problems that one needs to solve. At least in my world, simple parameterization of a string is almost always sufficient.
14:50cemerickah, parameterization, and (str (interpose "," seq)), etc.
14:54drewrWhat am I missing here? (map Math/sqrt [1 2 3])
14:55Lau_of_DK(map #(Math/sqrt %) seq)
14:57drewrLau_of_DK: Thanks. My brain was failing me there.
14:58drewrI knew I had to promote it to an IFn but I was doing identity for some reason.
14:59Lau_of_DKNo probs, imho Clojure should eat Java directly :)
14:59AWizzArdBut this is only because Math/sqrt is a Java method and not a Clojure function.
15:00AWizzArd(map clojure-fun col) is equivalent to (map #(clojure-fun %) col)
15:00AWizzArdor not?
15:01Lau_of_DKYes sir
15:07Chouseras long as you're only providing a single col argument to 'map'
15:09drewrI wonder if it would be too magical to automatically promote things like Math/sqrt.
15:09drewrMaybe static methods only?
15:10drewrThey act functionally.
15:16Chouserthat's been brought up before. I think rhickey_ was open to the idea, though I'm not finding a reference right now.
15:16jgracin_I have what is probably a silly question, but I've got to ask it anyway. Is there any way to compile a clojure file which references some Java classes, but without having those Java classes in the classpath?
15:17ericlavigneWhy only static methods? Ball.throw (non-static) could be a function whose first argument is a ball, while ball.throw would be a similar function with one less argument (already received the ball object as its first argument).
15:18ericlavignejgracin_: perhaps you could refer to an interface which those java classes implement?
15:19chrisnI like the way ericlavigne is going
15:19chrisnThat exact feature would have made a lot of my opengl code a bit cleaner
15:19jgracin_ericlavigne: I'm trying to see if I can mix Clojure and Java code which have interdependencies and therefore cannot be compiled sequentially.
15:20Chouserjgracin_: you definitely need access to any classes you extend or interfaces you implement.
15:20jgracin_e.g. how would I compile A.java b.clj C.java in which A.java depends on code defined in b.clj and C.java, and b.clj depends on C.java
15:21jgracin_Chouser: I see
15:22Chousergen-class uses introspection to poke around in the superclasses and figure out what it needs to do
15:22ericlavignejgracin_: you can avoid such cyclic dependencies by breaking your code into smaller pieces.
15:22Chouserwhat jgracin_ described isn't cyclic
15:22chrisnericlavigne: perhaps what you describe is how partial should work w/r/t java interop?
15:23Chouserjgracin_: I think you might be able to get where you want to go with careful use of ant and tasks for compiling .clj files.
15:24cemerickhrm, clojure.xml/emit doesn't do any string escaping at all...
15:24Chouserjgracin_: you might also look into using gen-interface (which I think doesn't need any of the classes it references) early, then javac all your .java files, then use 'proxy' in your .clj at runtime.
15:25Chousercemerick: yeah, that came up on the g.group. It's fixed in clojure.contrib.lazy-xml
15:26jgracin_Chouser: Interesting idea, I'll try that. Thanks!
15:27cemerickChouser: is lazy-xml being considered as a replacement for clojure.xml, or is an analogous fix going to slip in there eventually?
15:27ChouserPerhaps I should post an issue
15:27Chousercemerick: I'd like lazy-xml to replace clojure.xml, but I've got no indication any such thing is planned.
15:29Chouserclojure.xml has a couple correctness issues. string escaping, removing whitespace on parse, adding whitespace on emit
15:29cemerickyeah, it seems very prototypey
15:30ericlavignechisn: I am saying that we should think of the object to which a method belongs as being simply the first argument in a function. As a shortcut for Java methods, we should be able to say obj.method which implies partial application of obj to Obj.method.
15:30Chouserlazy-xml fixes a couple of those, though it still always trims whitespace.
15:31cemerickChouser: my brief run-ins with xml wizards have left me with the impression that whitespace handling is a decidedly tricky/ambigious thing when it comes to serialization
15:31chrisnericlavigne: I am checking out memfn...
15:32chrisndoesn't work for statics
15:34ericlavigneMaybe memfn expects you to pass something like Math.class as the second argument.
15:35ericlavigneI haven't used it.
15:35cemerickI can see how lazy xml parsing might not be an ideal standard approach, though. I certainly always want the whole doc, so the laziness is just overhead for me.
15:39ericlavignechrisn: I speak of the way I would do it. However, I don't yet know enough about Clojure to know if a better way has already been implemented. I'm certainly quite impressed by the parts of Clojure that I have used.
15:39chrisnI am in the exact same boat.
15:40chrisnOnce I get my demo project finished and lightly polished, I intend to go through the core source code and then through the contrib source code.
15:40chrisnI always ask questions that just require more knowledge of the apis that came with the system.
15:40ericlavigneThe proxies seemed overly complicated, so when I needed to create Java classes I just wrote some Java instead.
15:41chrisnI just forced that bastards to work my way ;).
15:46chrisnI wish you could create immutable classes from clojure. I am using defstruct all over the place and every once in a while I mistype a keyword. Which is a runtime error...
15:50Chouserchrisn: defstruct may produce a class with fields in the future.
15:51Chousercemerick: don't you do something clever along those lines?
15:51chrisnChouser: Is it possible to get compile time errors for certain classes of problems? I know, dynamic language blah blah, but I am not always using it in a dynamic way.
15:52cemerickChouser, chrisn: yeah, genbean. It's evolved quite a bit since my last post on it some months ago.
15:52cemerickI'll probably post an update after clojure goes 1.0 and I've updated it to match.
15:52Chouserchrisn: you can throw and exception from a macro
15:52Chousers/and/an/
15:52chrisnyep, good point
15:53chrisnI have buddy doing work on partially typing lanuages.
15:53chrisnAdding in hindley milner to python, but only where you have types
15:53chrisnworks pretty darn well.
15:53cemerickof course, the really nice stuff still requires that you drop any static type checking when creating the objects in question (e.g. when providing a delay for a slot in an object, rather than a strict value)
15:53Chouserchrisn: interesting. I've thought for quite a while that i wanted a language with optional static typing.
15:55chrisnI personally think types rock. I love Haskell and F#. I just love getting shit done a lot more ;) . Plus Lisp code just looks better.
15:55ChouserScala convinced me I do not want required static types. :-)
15:56chrisnHeh. With F#, you can always cast something to an object. So you can easily defeat the type system.
15:56chrisnI don't know about Scala.
15:57RaynesWe were just having a conversation in #Scala about why F# is horrible.
15:58chrisnoh jesus
15:58chrisnhere we go
15:58cemerickindeed. It's like a black hole.
15:58chrisnwhy is F# horrible?
15:59cemerickmaybe we can all just agree that all languages are horrible, and we'd all be better off running movable type presses.
15:59cemerickor something :-P
15:59chrisnanyone tried newspeak? then you can plug in your own type system.
16:00durkahey kotarak, i'm having strange problems with gorilla
16:00kotarakUh? *Strange* problems? That's no good.
16:01durkai start gorilla and do \sr in macvim
16:01durkagorilla shows "Connection started"
16:01durkamacvim freezes
16:01durkamacvim and java quickly climb to the top of CPU usage
16:02durkaif i kill gorilla (ctrl-c), macvim unfreezes and shows the repl, which of course doesn't work because gorilla is dead
16:03kotarakhuh?
16:03kotarakThat's strange.
16:04kotarakDid you change something to get this behaviour?
16:04kotarak(Other vim, ruby, clojure, contrib?)
16:04NafaiDoh
16:04NafaiFigured out my issue. :)
16:04NafaiI did 'git svn fetch' instead of 'git svn rebase' :)
16:04durkakotarak: i updated clojure and contrib to the latest svn
16:05kotarakHmmm... Will check. I had no problems up to now.
16:15durkakotarak: i have to go, but mention my name and i'll see it
16:16kotarakok. Just figuring out.
16:16kotarakSome change in Clojure broke it.
16:40RSchulzkotarak: You should check out this topic from the group: http://groups.google.com/group/clojure/browse_thread/thread/93e35885b0c0706d?hl=en
16:40RSchulzIt may be germane to what's happening to you in gorilla.
16:48kotarakRSchulz: thanks for the pointer
16:48kotarakWill investigate.
17:12mchurchI have a noob question that is probably not clojure related. I'm trying to create a socket. This: (def sock (new java.net.Socket "127.0.0.1" 5023)) : throws java.net.ConnectException : Connection refused. Why could that be?
17:13mchurchIs it something wrong in my code, or is the problem at the system level?
17:14karmazillaapparently, nothing is listening on your localhost port 5023
17:16RSchulzmchurch: You're aware that that particular java.net.Socket constructor immediately attempts to connect to the spcified host and port, right?
17:16mchurchRSchulz: I think I've figured it out, because ServerSocket could be instantiated.
17:16mchurchSo I instantiated a ServerSocket on that port, then a Socket, and the socket connected.
17:17mchurchSo, I guess they're connected. I didn't realize that I needed a ServerSocket before a Socket.
17:17RSchulzYou're attempting to connect to a listening socket in the same process?
17:17RSchulzNaturally, you'll need threads / Agents to make that work.
17:17karmazillaor non-blocking IO
17:17mchurchRSchulz: No, 2 different Repls
17:17RSchulzYes, there has to be socket listening to accept the connection request.
17:18mchurchI'm just trying to get a handle on sockets before I do the next stage of my current projects
17:18mchurchI didn't know what a socket was a couple weeks ago.
17:18RSchulzIt's OK. Sockets didn't know about you, then, either.
17:18RSchulzSockets, meet mchurch. Mchurch, sockets.
17:18RSchulzThere. Now you've been properly introduced.
17:18RSchulzAnyway, what sort of protocol are you working towards?
17:19RSchulzYou might want to work with slightly higher-level API such as the ones in Commons HTTP Client and HttpServlet.
17:21mchurchThis is for an RPC engine.
17:23karmazillaalso, for client code, you'd typically want to set timeouts before connecting, and thus not use a Socket constructor that connects automatically
17:23mchurchkarmazilla: Ok. I'm just prototyping right now.
17:23RSchulzIs th wire protocol already defined? Is it an external requirement? Or are you inventing it? Or using HTTP?
17:24RSchulzDistributed programs are so non-tivial, it's almost always a good idea to build upon as much infrastructure / framework / etc. as you can.
17:25Chouser...unless your homework assignment is to implement an RPC engine from the Socket level up.
17:25RSchulzOh, to be in school again...
17:29mchurchRSchulz: The protocol's already written. We have an RPC engine already written in SBCL and I'm writing a Clojure version of it.
17:29RSchulzI see. Well, at least you don't have to think about that part. Is it text or binary?
17:29mchurchRSchulz: Binary
17:29RSchulzOdd.
17:30RSchulzWhy?
17:31mchurchOh. One unrelated question. Sorry, but this has been bugging me: regarding import, what's the Clojure analogue of import java.io.*?
17:31mchurchIn the event that I want to import a whole package rather than just a list of classes.
17:32RSchulzThere's no "wild-card" import in Clojure.
17:32mchurchRSchulz: So you have to list all the classes?
17:32RSchulzYes.
17:33mchurchRSchulz: Got it. Thanks.
17:33RSchulzI personally don't think wild-card imports are a good idea.
17:34mchurchRSchulz: What do you dislike about them?
17:34RSchulzYou don't know what you're saying. In large systems that use many libraries, there can be clashes and you can get odd compilation errors.
17:34RSchulzI think you should say everything you mean, basically.
17:35mchurchRSchulz: Ah. Yeah, I can see that being a problem.
17:35RSchulzYou could conceivably even get sucessful compilation and run-time errors (during dynamic linking, most likely).
17:36RSchulzClojur at least doesn't make you say the package part over and over for each class from that package.
17:36mchurchRSchulz: Yeah. That would be horrible.
17:37RSchulzRealistically, it's not likely, though I've had the compile-time manifestation quite commonly in my own code.
17:37RSchulzI just couldn't see a better name for one of my classes than "Set", and so you can see the problem.
19:06durkakotarak: tracing gorilla reveals that after \sr gorilla goes into an infinite loop of de.kotka.gorilla.repl-ln/read-hook called with nil
19:15lisppaste8durka pasted "gorilla trace" at http://paste.lisp.org/display/72852
20:57MarkVolkmannIs there an absolute value function in Clojure? I've looked but don't see one.
20:57MarkVolkmannI know it would be easy to write my own, but don't want to do that if I don't have to.
20:59pjb3Math/abs
21:00pjb3That's the java one, but I've heard people complain because it doesn't work with all numeric types in clojure
21:00MarkVolkmannOh right! I forgot to just use Java.
21:01ericlavignepjb3: Also, methods aren't functions. It's always nicer to use something from native Clojure.
21:02pjb3ericlavigne: Is there a clojure function/macro that will return a function that wraps a method?
21:03ericlavigneI think that's what memfn is for, but I haven't used it yet.
21:04pjb3user=> (map (memfn Math/abs) [-3 3])
21:04pjb3java.lang.IllegalArgumentException: No matching method found: abs for class java.lang.Integer
21:04ericlavigneI think it's trying to find an Integer method called abs in the Math package :-(
21:05ericlavigneMaybe something like Math.class needs to be provided as another argument to memfn.
21:06dreishmemfn predates #() notation, and I believe it is generally considered obsolete now.
21:06Chouser,(map #(Math/abs %) [-3 3])
21:07dreishBut that's unrelated to the fact that 3 is an int, and Math/abs takes a double.
21:07pjb3(map #(Math/abs %) [-3 3])
21:07pjb3Right
21:07ChouserOr: (map #(.abs %) [-3M 3M])
21:07ericlavigneI thought Math.abs was overloaded to take a variety of possible arguments.
21:08durkaint, long, float, double
21:09dreish,(Math/abs -3)
21:09dreishclojurebot is being shy, but that gives me 3 at my repl.
21:16durkaso shy that it left the channel
21:26pjb3What's the easiest way to convert a map to a hash map?
21:27Chouseryou can use a java.util.Map in a lot of places that you'd normally use a hash map.
21:27pjb3In this case, I have a function that will passed a map
21:28pjb3and I will need to do some stuff with it, passing through it multiple times
21:28pjb3each time I pass through it, it needs to be in the same order
21:28pjb3I don't care what the order is, as long as it's the same each time
21:29Chouserjava.util.HashMap doesn't guarantee that?
21:30pjb3The map passed to the function could be an ordinary map
21:30pjb3I want users to be able to do
21:30pjb3(myfunc {:x 1 :y 2})
21:31pjb3Actually now that I think of it, I can probably just use (seq themap) in my function
21:32Chouseryes, I would think so.
21:32pjb3because I don't need to use it associately while processing it in my function
21:32pjb3associatively
21:35Chouser(into {} themap) if you really want a PersistentHashMap
21:37pjb3Wouldn't it have to be (into (hash-map) themap)?
21:38Chouserthat's fine too
21:39pjb3What's the difference between array map and hash map?
21:39pjb3or right, the array map preserves insertion order
21:40pjb3In clojure {} gives you an array map?
21:40pjb3Has it always been like that?
21:41pjb3I thought the default was hash map
21:41Chouserhm...
21:42rhickeypjb3: array map preserves initial order, multiple insertions will cuase it to transition to hash-map
21:43rhickeycause
21:44pjb3multiple being some large number?
21:44pjb3user=> (class (assoc (assoc (assoc {} :a 1) :b 2) :c 3))
21:44pjb3clojure.lang.PersistentArrayMap
21:45rhickeyuser=> (def m {1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1})
21:45rhickey#'user/m
21:45rhickeyuser=> (class m)
21:45rhickeyclojure.lang.PersistentArrayMap
21:45rhickeyuser=> (class (assoc m 9 1 10 1))
21:45rhickeyclojure.lang.PersistentHashMap
21:45pjb3I see
21:46pjb3That makes sense, has it always been like that or was that a change recently?
21:46rhickeyalways been a transation, recently made sure small maps were array maps, including {}
21:46rhickeytransition
21:47pjb3For some reason I remember doing (array-map :x 1 :y 2) for small maps that I needed to have a specific order for
21:48pjb3What happens if you have a large map that you need insertion order preserved for?
21:48Chouseryou can still do (apply array-map coll)
21:51pjb3Ok, and then you just need to make sure to know that if you assoc onto that, you'll get back a hashmap
21:51Chouserright
22:31rhickeylarge array maps are a bad idea perf-wise
22:51gnuvinceGrrr... I like Haskell and all, but sometimes they can make things so hard to understand...
22:52Nafairhickey: Thanks for all of the hard work getting Clojure working on Android, you rock.
22:52Nafairhickey: I verified it also works on an actual device :)
22:53NafaiI've updated the README that is on github that includes the svn revision number and also to comment out the bean function
22:56gnuvinceNafai: you mean, Clojure can be used to create application on Google's Android?
22:56Nafaignuvince: Yup!
22:56gnuvinceThat.s so cool :)
22:57Nafaihttp://github.com/Nafai77/helloandroid/tree/master
22:58akingNafai: you might also want to add a comment about increasing the heap size when compiling with dx
22:59akingNafai: or just update the build.xml :)
22:59Nafaiaking: I didn't have to do so
22:59akingRich did - and so did I - runs out of mem on XP
22:59Nafaiaking: What change did you have to make? I can make it and upload it
22:59NafaiYeah, I'm on a 64-bit vm on Linux :)
23:00akingFrom rhickey earlier: FYI, what I got running was this: http://github.com/Nafai77/helloandroid/tree/master, with no changes to it other than adding <arg value="-JXmx1024M" /> to the dex target in build.xml since I was getting out of mem errors there
23:02NafaiOk, cool
23:02NafaiI'll push that change
23:02NafaiI might start porting over some of the sample applications to Clojure
23:03akingNafai: I'm running emacs/slime under XP with a remote repl to my 64bit linux box for most of my clojure work - but used XP only for ANdroid testing. Eventually I'll get Android setup under linux
23:03NafaiCool
23:06NafaiUnfortunately, ddms doesn't run on 32-bit Linux at the moment, since it links against 32-bit swt librarie
23:06NafaiChange pushedd
23:07akingNafai: you mean "ddms doesn't run on 64-bit linux"?
23:08NafaiYeah, :)
23:15gnuvinceHmmm
23:16gnuvinceFrom Real World Haskell "Fewer parentheses leads to reduced mental juggling while reading a function."
23:16gnuvinceI'd disagree with that: fewer parentheses means you need to remember the proper operator priorities
23:19mattrepland mentally decoding $
23:21Chouserlooking back at my Scala code, I'd have to agree.
23:23ChouserReducing parens does give an overall look of simplicity -- it does not appear to be tangled or deeply nested.
23:23Chouserbut both are illusions. It may be tangled and deeply nested, you just can't tell. In fact it is quite difficult to tell what the heck is going on at all.
23:25falconaiany one have a quick example of how to use the "read" function? (read "(doc read)") obviously doesn't return any data structure
23:25rhickeyI find Haskell particularly painful to read due to precedence etc - I'd much rather have sexprs
23:25Chouser(read (java.io.PushbackReader. (java.io.StringReader. "(doc read)")))
23:26rhickeyfalconai: (read-string "(doc read)")
23:30falconaiso it looks like a sequence is returned by read-string...but it has to be a tree where as sequences are usually linear ... how do i traverse this tree?
23:31Chouserfalconai: no, it's returning whatever literal object the text represents
23:32Chouserlist, map, vector, etc.
23:33falconaii see...what i am trying to do is the following:
23:34falconaischeme's frtime (a CELLs like data flow framework) let's one do something like this: (even? 2) which returns true (like clojure) (even? seconds) switches true/false every second
23:35falconaischeme does this by extending its evaluator...i guess in clojure it would mean that between reader's output and the compiler, i would have to get access to the forms, manipulate them and send them on to the compiler...
23:36falconaidoes it make sense?
23:37ChouserI suppose.
23:38Chouserthere's code in clojure.contrib.walk for walking arbitrary clojure s-expr trees and making replacements.
23:38Chouseryou could run the reader yourself, I suppose, and then process the results and finally eval.
23:39Chouser...or you could write macros, which are given the already-read s-expr trees to work with
23:39falconaidoes walk operate on character based s-expr or forms returned by reader?
23:40Chouser...or you could take advantage of built-in clojure features to get what you want without messing the the structure of the programs
23:40Chouser'walk' operates on the data-structures returned by 'read' which are the same as what are passed to macros
23:40Chouserfalconai: there has been some discussion of "cell" implementations and "reactive programming" on the google group, including a couple of implementations.
23:42falconairight, i saw that (I think my original message might have started the main discussion)...but as far as I can tell, frtime is a more robust system...several years of use, several papers and a dissertation behind it
23:42Chouserok
23:44Chouserstarting with 'read' seems like a hard way to go.
23:45falconaiso a reactive expression such as (even? seconds) needs to be converted to a non-imperative expression involcing agents and watchers...but the end user should only see the reactive version (and not code related to agent watchers)...
23:45falconaiwhat is a good way to do that? (keeping in mind that reactive expressions can turn programs "inside-out")
23:46Chouserwould a macro be unacceptible? (react (even? seconds))
23:46falconai...i have never programmed in clojure, scheme, CL, etc....so I am starting as ignorant as can be
23:47falconaiI think (react (even? seconds)) may end up being the pragmatic solution...but what about when these reactive values are nested: (react (even? (+ (* temperature 100) seconds))) where temp and sec are reactive...will i be able to use
23:48falconaimacros to 'walk' the expression tree and get at the reactive values?
23:48Chouseryes
23:49falconaigood, encouraging...is there a way to make the REPL go through my macro for each new expression? (or is that the same as messing with the reader?)
23:49Chousera macro named react in the above example would be given the entire tree of s-expressions, and would be expected to return a new tree of s-expressions to be evaluated in their place.
23:49falconaiideally, i'd still like to avoid telling clojure explicitly about reactive values...i'd like them to be transparent (which may not be possible in a clean way)
23:51Chouserwell, you could write your own repl (not terribly hard) and process all expressions after 'read' and before 'eval'. But wouldn't it then be impossible to provide any non-reactive expressions?
23:51falconaiChouser: is textjure some sort of graphic REPL? for some reason i get that impression...and i'm very interested in something like it (lifting clojure's environment to something similar to spreadsheets)
23:52ChouserI plan for textjure to include a repl and a text editor using Swing widgets instead of a plain text terminal.
23:54falconaisounds good, do you have an ETA on it? :)
23:55Chouserwell, the repl largely works already, but without a good text editor I don't think it provides much benefit.
23:56ChouserI want vi-like keybindings, and passable syntax highlighting and indentation support.
23:57Chouserright now I'm spending most of my "clojure time" fixing up the web page docs, but I hope to get back to textjure in another week or two.
23:58falconaispeaking of which, http://clojure.org/repl_and_main is empty
23:59Chouseryeah, rhickey_ added a few blank pages. I'm not sure exactly why. :-)
23:59gnuvinceprobably to have people fill them up ;)