#clojure log - Jun 12 2009

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

0:00 polarbizzler: that will do the trick thanks

0:00 i was searching for some examples like on that link forever

0:44 Drakeson: what is the inverse of interleave?

0:46 Chouser__: take-nth

0:46 or partition with destructuring

0:54 Drakeson: thanks

1:17 dufflebunk: I'm looking at the online api docs for if-let, "(if-let bindings then)" and then it says "If test is true, ..." but there's no "test" in the syntax... just "bindings" and "then".

1:17 Should it be (if-let test bindings then) ?

1:17 dnolen: the binding is the test

1:18 ,(if-let [x nil] true false)

1:18 clojurebot: false

1:18 dnolen: ,(if-let [x 1] true false)

1:18 clojurebot: true

1:18 dufflebunk: Ah, ok

1:19 thanks

1:19 dnolen: np

1:21 dufflebunk: so that's what the "binding-form test" part meant.

2:53 cgrand: eleftherios: I'm here

3:09 eevar2: yay, clojure on github

3:12 opqdonut: proxy can't define new methods?

3:12 hiredman: nope

3:15 opqdonut: why :/

3:16 hiredman: use gen-interface + proxy

3:18 opqdonut: gah, i'll just return a map of functions

3:19 frodef: is there no way to get cond with implicit progns?

3:19 I mean, how do I do multiple exprs in a cond clause?

3:19 hiredman: you mean do

3:20 and no

3:20 frodef: jhiredman: progn is "do" in clojure?

3:20 hiredman: you coud just a multimethod instead

3:20 use a

3:20 frodef: I think so

3:21 never used progn or whatever language it is from

3:21 frodef: right, it's the same.

3:21 thanks.

4:45 I'm trying to write a swing viewer for my model. What's the good way to keep the model state?

4:46 jdz_: a ref?

4:46 frodef: can/should I do like the java-people and create a class that keeps its state in members?

4:46 jdz_: or an atom?

4:46 a map (or struct-map) then?

4:47 frodef: jdz: ok, I'll look at those. thanks.

4:48 jdz: maybe you want a map in a ref/atom

5:18 Chousuke: frodef: usually you'll want something immutable wrapped in a reference type.

5:18 a single ref wrapping a map if usually a good starting point

5:26 opqdonut: what could cause clojure.lang.Compiler.LOADER to be unbound?

5:27 guess I should be creating my own DynamicLoader

5:29 that did the trick

6:57 is there an easy way to access class members by string names

6:58 mccraig: u want to access a field or call a method ?

6:58 of an instance of a java class ?

7:00 opqdonut: http://gist.github.com/128577

7:00 opqdonut: field

7:00 of an instance

7:00 mccraig: shows how u can access a field, even a private one

7:00 taking the example of an Agent's state

7:00 opqdonut: heh, terrible

7:01 frodef: maps are immutable also, right?

7:01 mccraig: 'course, the SecurityManager has to be configured lax to permit access to private fields

7:02 jdz: frodef: yes

7:03 opqdonut: well i don't need private fields :)

7:03 mccraig: skip the setAccessible call then, and ur away

7:04 eevar2__: ,(doc bean)

7:04 clojurebot: "([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties."

7:04 eevar2__: ^^ opqdonut

7:05 opqdonut: mccraig: yah

7:05 eevar2__: ?

7:07 eevar2__: may or may not do what you need ;)

7:07 opqdonut: well, it does not

7:07 mccraig: http://paste.lisp.org/display/81759

7:07 mccraig: eevar2__: JavaBean properties only include fields which have a corresponding java get...() method

7:08 eevar2__: hmm.. and i see he asked for class members, guess bean may not be appropriate for that

7:19 mccraig: opqdonut: does set! not work for u, since it's public fields ?

7:41 opqdonut: mccraig: i need to set! by string name

7:41 but gtg ->

7:55 adityo: newbie question: how do i read from standard input?

7:57 achim: adityo: read-line, for example

7:58 adityo: achim: thanks

7:58 achim: adityo: in is the standard input, a java Reader, you can call java methods on it if you need anything special

7:58 frodef: any hints on how to best do an event queue between two threads?

8:02 cemerick: frodef: easiest way is to put a persistent queue in a ref, and access it from your threads inside transactions

8:03 frodef: cemerick: can I do a blocking read that way?

8:03 Chouser: frodef: I'd look at java.util.concurrent.BlockingQueue

8:06 adityo: achim: cool

8:10 Chousuke: http://www.making-the-web.com/misc/sites-you-visit/nojs/ :/

8:12 Apparently, it's possible to for a site to sniff your history by abusing CSS and iframes. I wonder if that's even fixable

8:22 asbjxrn: I'd call it guess, and not sniff.

8:23 Since it relies on showing a link and detecing if the browser displays it as visited or not.

8:23 But still..

9:48 cemerick: is the github repo now "official"? I see people tweeting about it, but haven't seen an announcement from rhickey

9:48 Chouser: cemerick: I haven't seen an announcement either.

9:49 It's not clear to me yet if github or assembla will host the official primary repo.

9:50 cemerick: I *thought* the decision was to use github for the SCM, tools on assembla, but yeah, it's unclear.

9:50 There's a lot of watchers on the github repo already. Word travels fast. :-)

9:50 Chouser: :-)

9:50 Chousuke: it doesn't really matter who hosts the main repo anyway ;P

9:51 cemerick: yeah, same here

9:51 Chousuke: you can just clone it to your favourite git service anyway

9:51 duck1123: is there a fn to convert '(:a "a" :b "b" :c "c") to {:a "a" :b "b" :c "c"}

9:51 Chouser: Chousuke: depends on how much lag time you're willing to accept between a rhickey push and your own pull.

9:51 Chousuke: duck1123: apply hash-map

9:51 Chouser: well, yeah

9:52 * Chouser is willing to accept between 3 and 5 seconds.

9:52 Chousuke: github is a bit slow sometimes :/

9:52 but faster than SVN at google code :P

9:52 cemerick: well, a different clone from svn would have different sha1s, so that could get tricky if you start basing on a repo that isn't blessed.

9:53 Chouser: Chousuke: no, my point is if rhickey pushes to assembla, I'm not willing to always wait for a nightly poll that transfers it to github. Or whatever. I want my local copy to poll from where he pushes.

9:54 In fact, if I could pull directly from his working copy, that'd be neat. :-)

9:54 Chousuke: Chouser: right.

9:54 heh

9:54 Chouser: I think assembla+git works so that github actually does the hosting and assembla just provides some tools on top of that.

9:55 rys: I think that's what most people are looking for at the end of the day (to be able to clone rhickey's repo directly and pull from it, so there's no indirection)

9:55 Chousuke: git can have multiple remotes, so you could pull from several places.

9:56 Chouser: "I don’t think it would be wise to use github mode and integrated git together, even if they allow it."

9:56 I'm not sure exactly what that means, but I'm willing to wait for final conclusions/announcements.

9:56 Chousuke: I could have my own public clojure-fork on gitorious or something and then people could have a mainline remote and a chousuke-public remote if they're interested :P

9:56 rhickey: I've decided not to use assembla's built-int git, but to have it point to github

9:57 Chouser: ah, so no mirroring

9:57 rhickey: I'm actively working out the detils, just got IntelliJ all happy with the github version of Clojure

9:58 Chouser: right, assembla doesn't like to have 2 vcs options enabled, go I'm going with the github support

9:58 walters: i wonder if google is still paying some guy to try to make svn better

9:59 Chousuke: rhickey: is your git repo already public on github?

9:59 rys: I _think_ they're directly working on git (TortoiseGit in particular), if memory serves, so I'd bet on seeing git support at googlecode at some point

10:00 Chouser: Chousuke: people are twittering about it.

10:00 rhickey: http://github.com/richhickey/clojure/tree

10:00 no pushes yet

10:00 Chousuke: github's search didn't find that. :/

10:01 is clojure-contrib going to move too if this is successful?

10:02 rhickey: Chousuke: yes

10:02 Chousuke: great.

10:02 rhickey: still working out how to organize it - seems like a good time to make the ports (ClojureCLR and ClojureScript) stand alone

10:03 I've come to really dislike gcode's issue system, but need to find a way to port issues over to assembla

10:04 Chousuke: git has submodule support so you could have the contrib master repo contain those, but perhaps it's not worth the added complexity

10:04 I still don't know how to use git submodules very well :/

10:04 easier to just clone things separately

10:04 duck1123: they should be moved to clojure-extras or something IMO

10:04 Chouser: I doubt it'd be worth anything like that. Java's classpath allows sufficient namespace integration.

10:04 Chousuke: but, heh, I just cloned your repo. took about 5 seconds. :P

10:05 * Chousuke remembers git svn clone taking about 30 minutes

10:05 Chouser: I'll be happy for clojurescript to have less visibility. :-P

10:06 rhickey: I could use help devising and implementing plans for all of this, now that I think I know where we are going

10:06 duck1123: is it usable yet? It looked interesting, but I couldn't figure out how to use it. (not that I really tried)

10:07 Chousuke: rhickey: do you think there's any way to automate moving issues to assembla? :/

10:07 Chouser: duck1123: it's pretty out of date now. It was in decent shape, nearly usable before the "lazier" changes, but I haven't kept it synced.

10:08 duck1123: I'm not really interested it putting much more effort into it at least until clojure-in-clojure.

10:08 rhickey: Chousuke: there is this on the assembla side: https://www.assembla.com/wiki/show/breakoutdocs/Ticket_REST_API

10:08 adityo: quit/

10:08 duck1123: Chouser: I had to write some JQuery recently, and I kept wanting to write in clojure

10:08 Chouser: duck1123: :-)

10:09 rhickey: google is notoriously bad about data export

10:10 Chousuke: rhickey: hmm, right.

10:11 rhickey: http://code.google.com/p/support/issues/detail?id=1689

10:12 http://code.google.com/p/support/issues/detail?id=148

10:15 Chouser: "we are *actively* working on this right now" (50 minutes ago) -- nice

10:37 Drakeson: do we have a function similar to this: (defn de-interleave [n coll] (map #(take-nth n %) (take n (iterate next coll)))) ?

10:37 e.g. (de-interleave 2 [1 2 3 4 5 6]) -> ((1 3 5) (2 4 6))

10:42 cgrand: ,(apply map vector (partition 2 [1 2 3 4 5 6]))

10:42 clojurebot: ([1 3 5] [2 4 6])

10:43 cgrand: (not lazy)

10:47 Drakeson: Is there a lazy version of (apply map vector coll) ? I would call it transpose.

10:47 (transpose [[1 2 3][4 5 6][7 8 9]]) -> [[1 4 7][2 5 8][3 6 9]]

10:52 duck1123: Does anyone know of any good search engine like sites (other than google) where I can input a class and get the javadoc for it? Preferably with a search plugin.

10:54 Drakeson: I would appreciate an interface to such in slime (via C-c I)

10:56 duck1123: I have an javadoc emacs plugin, but I never use it much

10:56 I had to add all the javadoc sources, and it was kinda buggy

11:00 cemerick: duck1123: yahoo used to have a great javadoc search feature, though they pulled it last wee (don't know why)

11:00 duck1123: I found javadoconline.com, but I'm not sure if I really care for it yet

11:01 cemerick: I'd love to have something like http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html for javadoc

11:06 hiredman: ~jdoc String

11:06 http://www.docjar.com/ has decent javadoc coverage

11:08 duck1123: hiredman: thanks, I'll give that one a try

11:14 j-dot: duck1123: if you have the Google Toolbar installed, there is a custom search button here: http://www.javac.info/jdk_search.xml

11:16 duck1123: j-dot: I don't. I use the firefox omnisearch plugin. (makes the address bar behave like chrome)

11:17 j-dot: cool, for anyone else who's interested, the write-up and link to install it is here: http://gafter.blogspot.com/2009/03/jdk-api-search-in-google-toolbar.html

11:19 duck1123: i think i just need to start using the emacs plugin i had again

11:43 Chousuke: I think Mark Volkmann's clojure article should perhaps be featured on clojure.org. It seems great for people looking for an introduction into Clojure.

11:44 Appears to be much better organised and up to date than the wiki pages :P

11:48 drewr: duck1123: The Clojure Search does a pretty good job: http://is.gd/ZUZ8/BufferedReader

11:49 hiredman: it would be neat if github did pubsub so I could just have clojurebot subscribe

11:50 duck1123: hiredman: agreed

11:50 hiredman: of course then I would need to figure out pubsub

11:50 duck1123: is clojurebot on xmpp yet?

11:50 hiredman: nope

11:51 duck1123: I've been meaning to work on a clojure library for igniterealtime's xmpp library when I get around to it

11:52 hiredman: I've started a few times

11:53 duck1123: is anyone else here currently using clj-record?

11:54 currently, (get-record 7) throws an exception if that id doesn't exist. Personally, I think it should return nil. Any opinions?

11:55 cp2: hrm

11:55 well, it depends on how you are using it i suppose

11:56 'nil' could be a perfectly legal value in your application

11:56 duck1123: the record will always be a map though

11:56 so in this case nil is an illegal value

11:57 cp2: yeah, then in that case

11:57 i would prefer it returning nil

11:57 because you can just do (if-let [record (get-record 7)] ...

11:58 duck1123: that's exactly how i've been using it in my fork

12:02 hiredman: ugh

12:03 git shas are not as nice as svn revisions

12:03 Chousuke: heh :P

12:04 hiredman: ~latest

12:04 clojurebot: latest is 1382

12:05 Chousuke: revision numbers only make sense locally to a branch. In that respect, hg does it right.

12:05 hiredman: how is that even going to work?

12:05 just hold the date of the last check in?

12:05 Chouser: hiredman: ooh, I like that idea

12:05 Chousuke: or the commit message.

12:07 duck1123: first line only

12:08 Chouser: commit message is the "normal" git way I think, but when we have a single official repo, timestamp would give a nice sense of whether you're up to date or not

12:08 Chousuke: the problem is, when doing commits, git actually records the date.

12:09 but that's no guarantee of when the commit will appear in the mainline

12:09 you could have it in the private repo for half a year, and then when you finally merge, you will have half-year-old commits at the top of the log :)

12:09 Chouser: wouldn't the merge get a new timestamp?

12:10 Chousuke: the merge commit does but the actual commits being merged are separate.

12:11 I can't remember whether the merge commit ends up at the "top" or not :/

12:11 hmm, seems like it does.

12:12 hiredman: I get two dates from the github api

12:12 :committed_date and authored_date

12:12 Chousuke: maybe committed_date means "pushed_date" instead :/

12:15 hiredman: ugh

12:16 the dates from github have a single colon in the timezone specifier that prevents SimpleDateFormat from parsing them

12:18 duck1123: I wish SimpleDateFormat could work with xsd:dateTime

12:19 it's so annoying to have to write custom code for that. (or use jodatime)

12:19 hiredman: (.replaceAll datestring "([+-])(\\d\\d):(\\d\\d)" "$1$2$3")

12:20 so horrible

12:22 doug_: Is there an easy way of making a hash-set from a coll? I resorted to this: (defn hash-set-from [coll] (reduce #(conj %1 (keyword %2)) (hash-set) coll))

12:23 hiredman: there are several

12:23 ,(apply hash-set '(1 2 3))

12:23 clojurebot: #{1 2 3}

12:24 hiredman: ,(into (hash-set) '(1 2 3))

12:24 clojurebot: #{1 2 3}

12:24 dnolen: ,(set [1 2 3 4 5])

12:24 clojurebot: #{1 2 3 4 5}

12:24 hiredman: ,(class {})

12:24 clojurebot: clojure.lang.PersistentArrayMap

12:24 hiredman: ,(class #{})

12:24 clojurebot: clojure.lang.PersistentHashSet

12:24 dnolen: set takes a collection and produces a hash-set

12:25 doug_: thanks very much for hash-set tips.

12:27 Chousuke: hmm.

12:30 ,(apply hash-set [1 2 3 4 5])

12:30 clojurebot: #{1 2 3 4 5}

12:30 Chousuke: :)

12:30 oh, it was up there.

12:31 missed it ;/

12:40 duck1123: is there a version of find-doc that just returns the symbols?

12:41 I can often figure out what I'm looking for just by seeing the name

12:43 Chousuke: duck1123: unfortunately not :/

12:46 marklar: lisppaste8: paste?

12:46 clojurebot: paste?

12:46 clojurebot: lisppaste8, url

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

12:46 marklar pasted "Show-doc" at http://paste.lisp.org/display/81772

12:47 marklar: duck1123: not exactly what you were looking for, but it may help. Wish I could remember who wrote it

12:47 * thickey raises hand

12:47 marklar: thickey: Thanks again :)

12:47 thickey: np :)

12:49 duck1123: that actually looks more useful than what I was asking for

12:49 stuartsierra: Android Scripting Environment! http://tinyurl.com/ku2gj5

12:49 thickey: does anyone know more about the Clojure Object Explorer that was shown at the Bay Area Clojure Meetup?

12:49 marklar: stuartsierra: whoa, thats cool

12:51 technomancy: thickey: that'd be replaca's project

12:52 thickey: http://github.com/tomfaulhaber/clj-explorer/tree/master

12:52 thickey: technomancy: thanks

13:26 replaca: thickey: yeah, I know a little about it :-)

13:27 thickey: anything I can tell you besides the pointer technomancy sent you? It's still very young.

13:28 thickey: replaca: i don't have any questions at the moment. i just wanted to see it in action

13:29 cp2: shutup.lua

13:29 hehe

13:30 replaca: thickey: cool. You can just grab it and play. But there's no doc yet

13:31 the interesting things are that you can click on the text and it expands or contracts stuff

13:31 and you can change the pretty print dispatch function so that you can have it operate on XML, json or what ever

13:32 thickey: replaca: cool stuff. thanks

13:32 replaca: thickey: enjoy, and keep an eye on it cause I'll be making it "more real" as we go along

13:49 rhickey: name solicitation time again: single-assignment, block until available dataflow variables create with ___, assign with ___, deref with deref/@

13:50 dataflow, flow, flow1, ivar

13:56 cemerick: a little more context is probably necessary :-)

13:57 is this being bolted into refs, or is it something else entirely?

13:58 Chouser: this isn't future?

13:58 more like a single-item BlockingQueue?

13:59 rhickey: it's a lot like an Oz dataflow var, without any unification bits. It's like a future but the source isn't determined at creation time - someone must come along and write to it, any readers arriving prior to that will block, all release with value once written, subsequent readers will always see that value, subsequent write throws

13:59 hiredman: ooo

14:00 rhickey: so, not like a queue in that there are multiple readers of the one value

14:00 Chouser: oh, multiple readers for a single value ... right.

14:00 cemerick: hrm, interesting.

14:01 hiredman: worm

14:01 cemerick: personally, I'd keep away from the flow-related names, which generally are associated with cells impls and constraint propagation in general (in my experience)

14:01 Chouser: future could be built on it

14:01 hiredman: http://en.wikipedia.org/wiki/Write_Once_Read_Many

14:03 lisppaste8: rhickey pasted "flows" at http://paste.lisp.org/display/81776

14:03 Chouser: (let [x (dam)] (release! x 5))

14:03 rhickey: cemerick: right, I'm not happy with flow and dataflow, people use them for very different things

14:05 was ivar in Haskell

14:05 IVar

14:06 but var already has implications

14:06 Chouser: it's a blocking bucket

14:07 rhickey: how appealing

14:07 Chouser: hehe

14:07 a cork

14:08 hey, I implemented this using a wather

14:08 watcher

14:09 on an IRef. ...an atom in my case.

14:09 rhickey: what prevented subsequent assignment?

14:10 cemerick: gap? e.g. once filled, hard (impossible) to fill again

14:10 Chouser: hm, I guess more accurately I could have used this. Instead I wrote await-iref

14:10 rhickey: http://en.wikipedia.org/wiki/Futures_and_promises

14:11 according to that, 'promise' fits

14:12 Chouser: http://paste.lisp.org/display/81237#2 -- await-iref

14:12 cemerick: rhickey: of course, scheme's promises are clojure's delays

14:13 rhickey: right, it's a mess

14:13 same thing called promise, ivar, dataflow var

14:13 cemerick: the latter are nearly meaningless to me :-)

14:13 latter two...

14:14 Chouser: and just as bad, promise and var mean other things in other places

14:14 rhickey: but promise was a bad name for what Clojure calls delay, IMO, and fits this well

14:15 lisppaste8: rhickey annotated #81237 "flow/promise" at http://paste.lisp.org/display/81237#3

14:15 Chouser: interesting that it's got a constructor that creates a new identity, but takes no args.

14:16 rhickey: thus the promise notion

14:16 someone else is going to complete the construction

14:17 dnolen: curious are there particularly good use cases for dataflow vars, never used anything like them before.

14:17 Chouser: what does the I in Haskell's IVar stand for?

14:17 rhickey: immutable

14:17 Chouser: ahhh

14:18 * technomancy considers the term invariable

14:18 rhickey: from Id I-vars

14:18 cemerick: actually, hiredman mentioned 'worm', which doesn't seem so bad (accurate and unambiguous, anyway)

14:19 rhickey: I'm not putting a worm in my language

14:19 technomancy: spit/slurp is bad enough, eh? =)

14:19 rhickey: var1 once

14:20 hiredman: I like promise

14:20 cemerick: +1 promise, compared to the other options

14:21 Chouser: is this really the only thing we're ever going to want to promise?

14:21 that's also a word that's used somewhat coloquially when talking about the api.

14:22 hash-maps return integer keys in order, but that's not a promise.

14:22 on the other hand, it's not nearly as bad as the two meanings of map, so maybe we're ok.

14:22 rhickey: pvar

14:22 Chouser: var-once

14:23 rhickey: since if you are reading another thread better be writing

14:23 :)

14:23 * rhickey likes pvar

14:24 Chouser: I don't like the re-use of "var" (in my last suggestiong either)

14:25 maybe "var" can be renamed. :-)

14:25 replaca: speaking of futures and pvars, is there any way to tell if a future has a value other than waiting for it? I'd liek to be able to look at the value if it's there but go off and do something else if it's not ready yet

14:25 *LIKE

14:26 Chouser: (.isDone f)

14:26 rhickey: replaca: future-done? will go in with this checkin

14:27 right now setting the promise/pvar/whatever is a fn call, but I'd like to encapsulate that, maybe if we name that we'll get some clues

14:28 cemerick: jail/capture?

14:28 rhickey: (put pv 42)

14:28 * cemerick is bad at this game :-/

14:28 hiredman: isn't pvar that parallel var thing?

14:28 ah, pvalues

14:30 Chouser: you deliver on a promise, don't you?

14:30 hiredman: ooo

14:31 Chouser: or fulfill

14:32 promise-val, deliver-val!

14:32 :-/

14:33 rhickey: (def p (put))

14:33 (put p 42)

14:34 Chouser: I like the namespace conservation, but that might be a tad confusing.

14:34 rhickey: I wish it had a more meaningful connection to put options, where the noun/verd thing works

14:36 Chouser: these won't allow validators?

14:36 rhickey: no

14:36 Chouser: what about watchers. ;-)

14:37 rhickey: these are supposed to be fairly primitive things

14:37 the first Clojure workflow constructs

14:40 gnuvince: Are some of you going to participate in this year's ICFP contest?

14:41 rhickey: gnuvince: would be fun, don't know about my availability yet

14:53 variable ?

14:54 replaca: rhickey: oops, wandered off. Thanks!

14:55 rhickey: (def b (unbound))

14:55 (bind b 42)

14:55 bindable

14:55 replaca: Chouser: I was just reading a post where you were railing against undocumented interfaces and now you're recommending one to me. :-)

14:57 Chouser: replaca: :-) :-)

14:57 hiredman: bind doesn't suggest blocking

14:57 rhickey: bind doesn't block

14:58 Chouser: (def b (will-bind)) (bind b 42)

14:58 hiredman: fine

14:58 rhickey: pending

14:58 Chouser: hm!

14:58 cemerick: ooh, I just thought of pending too :-)

14:58 gnuvince: Another ref type?

14:58 Chouser: (def b (pending)) (pend b 42) ?

14:59 rhickey: gnuvince: not really, in that refs are really for state, these are one-shots

14:59 cemerick: (def b (pending)) (complete b 42) ?

14:59 * rhickey was thinking pending/bind

14:59 zargon_: hmm, whats the difference between :while / :when modifier in for loops?

14:59 gnuvince: rhickey: what's the use case scenario?

14:59 hiredman: :while is like take-while :when is like filter

14:59 cemerick: pending/deliver, pending/fulfill

15:00 zargon_: hiredman: thx

15:00 cemerick: rhickey: doesn't that guarantee confusion given binding (totally different concepts, but I guess that's my point)

15:00 rhickey: gnuvince: plenty, you can build whole workflow systems out of things like this - see Mozart/Oz

15:00 cemerick: yes, just riffing

15:01 Chouser: I like pending -- seems more specific than promise

15:01 provide? put? fulfill?

15:01 rhickey: pending/fill

15:02 replaca: rhickey: i like pending/fill!

15:02 zargon_: ,(for [x (range 3) y (range 3) :while (< y x)] [x y])

15:02 clojurebot: ([1 0] [2 0] [2 1])

15:03 zargon_: hmm, why is that? shouldn't that be empty?

15:03 it should stop immediately in the first iteration ...?

15:04 Chouser: :while applies to the level of the loop it appears after

15:04 zargon_: ahhh!

15:04 there's much more behind for than the docs suggest ...

15:05 rhickey: Chouser: no, while should be an abort as soon as false

15:05 zargon_: huh?

15:06 Chouser: it aborts y in that example, but not x

15:06 rhickey: hrm

15:06 how could one bail overall then?

15:07 bhurt: Stupid question of the day: if I pass nil into a java function, does it become null?

15:07 Chouser: bhurt: yes, nil is null

15:07 bhurt: Thanks.

15:09 Chouser: rhickey: well, you can put a :while on x as well, but of course you wouldn't be able to examine y there.

15:30 rhickey: Chouser: yeah, I guess that's how it's always been: http://groups.google.com/group/clojure/browse_frm/thread/34724b7b13b3e2ed/6f4ed88d53f12423?#6f4ed88d53f12423

15:31 do we need :bail ?

15:31 Chouser: I don't think I've needed it, but that's probably not saying much.

15:33 grammati: :break-if ?

15:37 rhickey: void/fill ?

15:38 Chouser: heh

15:38 pending/supply?

15:38 pending/unpend?

15:38 pending/depend?

15:39 rhickey: pending is not growing on me, I kept forgetting it, and it's not a noun, unless we start calling these things pendings - ick

15:42 promise/fill or promise/deliver work - lots of people misspell fulfill

15:42 zargon_: rhickey: would you mind to add a clarifying statement to the api docs on "for"?

15:43 rhickey: zargon_: seems to need it

15:43 zargon_: thx

15:48 rhickey: pend/fill ?

15:48 Chouser: not bad. you're ok calling them "pends"?

15:49 rhickey: I don;t know

15:49 hiredman: a pend is a hallway

15:49 Chouser: promise/fill isn't too bad either

15:51 grammati: I missed most of the conversation and don't really know what you're talking about, but... how about a "deferred"? (as in twisted)

15:51 rhickey: pendent

15:52 also pendant

15:55 wlr: defer/complete

15:55 cemerick: that's not bad

15:56 rhickey: defer syn/delay

15:56 we're not supplying the work at construction

15:57 pending/pendent is the right notion

15:57 cemerick: trap/fill?

15:58 j-dot: pendent/settle?

15:59 gnuvince: suspension/DISBELIEF! ?

15:59 kefka: If I'm doing lots (multi-MB) of binary I/O for IPC and mostly RPC, what resources (Clojure libraries, Java classes) are the fastest?

15:59 cemerick: gnuvince: :-D

15:59 gnuvince: If I understand correctly, we're looking for a noun/verb pair?

15:59 rhickey: gnuvince: constructor/setter

16:00 gnuvince: I got all these stupid ieads :-/

16:00 raincheck/cash-in

16:00 rhickey: you got a thesaurus handy?

16:01 You could look up synonyms for "suspension" or something like that

16:01 rhickey: don't we all? http://thesaurus.reference.com/

16:01 Chouser: wait, are you on the *internet*!?!

16:01 cemerick: get out of the house! They're in the tubes!

16:02 * Chouser sighs and gets back to multithreaded C++

16:02 j-dot: obligation/deliver, obligation/oblige?

16:02 gnuvince: ,defer

16:02 clojurebot: java.lang.Exception: Unable to resolve symbol: defer in this context

16:02 grammati: unbound/bind

16:03 gnuvince: oh wait, not a noun :-/

16:03 Chouser: ,(doc delay)

16:03 clojurebot: "([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force), and will cache the result and return it on all subsequent force calls."

16:03 kotarak: the eternal struggle for good names?

16:03 gnuvince: postponement?

16:05 kefka: Note on the above: can't use duck-streams (I don't think) because this is binary, not character data.

16:07 rhickey: need/fill

16:08 if our programs have needs they'll be that much closer to consciousness, AI here we come!

16:08 * rhickey ducks

16:09 hiredman: ~need

16:09 clojurebot: the world <reply>what the world needs is more higher order functions

16:09 gnuvince: we should have a wiki for those kind of things...

16:11 rhickey: demand/supply - did someone say that/

16:11 ?

16:11 wlr: announce/deliver

16:12 hiredman: debit/credit

16:13 gnuvince: ,promise

16:13 clojurebot: java.lang.Exception: Unable to resolve symbol: promise in this context

16:14 gnuvince: promise/deliver?

16:14 rhickey: the constructor will not actually fill in a value, that'll happen with the setter (once), right?

16:14 rhickey: gnuvince: right, it's a no-arg ctor

16:15 gnuvince: dig/fill?

16:15 rhickey: thus the preference for a noun that can also be used to refer to these constructs - that's why promise is good

16:16 gnuvince: What I slightly dislike about promise is that I think I've seen it used in other languages to delay a value and force it later.

16:16 That might be in SICP

16:17 rhickey: pend[ing] is nice because it hints at the blocking that will occur of you read before filled

16:17 gnuvince: pending I liked

16:17 But you said it was growing on you :-/

16:18 rhickey: wasn't

16:18 gnuvince: right

16:18 sorry

16:19 kotarak: imagine/realize

16:20 rhickey: first word noun is best

16:23 gnuvince: How do you feel about "raincheck" for the constructor?

16:23 rhickey: not too good

16:23 :)

16:23 gnuvince: No problem :)

16:24 Just surfing on thesaurus.com

16:25 pledge?

16:25 rhickey: promise/deliver seems decent

16:26 of course. in langs where these are primitives it just looks like variable declaration and assignment :(

16:30 Chouser: interesting that import is a macro

16:30 ...when require and use are not

16:30 kotarak: This changed lately, no?

16:30 Chouser: kotarak: oh, perhaps you're right.

16:31 indeed. import is a fn in 1.0

16:31 kotarak: thanks

16:31 rhickey: Chouser: require and use should be, but there will be some breakage because they are called by Java host programs. Will need fn versions too, that take classLoader arg

16:32 this to enable use of caller's classloader

16:32 Chouser: ok, that'll be nice.

16:36 rzoom: why does this work: (Float. ({:a "3"} :a))

16:36 and not this: (float ({:a "3"} :a))

16:36 Chouser: rzoom: float is a simple type case.

16:37 rzoom: (Float. x) call the object constructor

16:37 rhickey: last call - any objections to promise/deliver?

16:37 Chouser: The Float class has a constructor that takes a string.

16:37 duncanm: how do i take the last 5 elements of a seq?

16:37 there's no TAKE-LAST

16:38 rhickey: ,(doc butlast)

16:38 clojurebot: "([coll]); Return a seq of all but the last item in coll, in linear time"

16:38 kotarak: (drop (- (count the-seq) 5) the-seq)

16:38 rhickey: oh, 5

16:39 kotarak: Beware of (iterate inc 0)....

16:39 hiredman: heh

16:39 duncanm: if drop takes a negative number, i guess that works too

16:40 oh wait

16:40 i get it

16:41 it might be handy to have TAKE-LAST

16:41 Chouser: last could take an optional count arg

16:42 duncanm: right

16:42 kotarak: (defn take-last [n s] (drop (max (- (count s) n) 0) s))

16:42 rhickey: Chouser's idea is best, add n arg to last

16:42 Chouser: (reverse (take 5 (reverse x)))

16:43 hiredman: ick

16:43 rhickey: ow!

16:43 Chouser: :-)

16:43 hiredman: it seems like a lazy-seq and a N element ring buffer might be best

16:44 Chouser: can't be done lazily

16:44 kotarak: Because it's not a stopping time.

16:45 hiredman: oh

16:45 right

16:45 to put things in the buffer you would have to realize them, of course

16:47 rhickey: oh no, canceled/cancelled - Futures use double L

16:48 rzoom: can classes be passed as function arguments? e.g. (defn f [t v] (new t v)) to create an instance of type t, using v as the arg to the constructor.

16:48 this is not making clj happy

16:49 Chouser: rzoom: a class can be passed, but you cannot just call new on it then.

16:49 you'd need to call a method of the Class class, like (.newInstance t)

16:52 or something like: (clojure.lang.Reflector/invokeConstructor Integer (to-array ["5"]))

16:54 rzoom: looks like there is no way around that Reflector call, i guesss.

16:55 Chouser: there are a couple techniques that might help, depending on your situation.

16:55 Sometimes I've been able to pass around a clojure fn that will construct the object, rather than the class itself.

16:56 rzoom: basically, i am just looking for a easy way to convert strings to various basic java types

16:56 hiredman: erm

16:56 easiest is read-string

16:57 Chouser: that's even slower than the reflector call. :-)

16:57 rzoom: well, taking a map as an arg

16:57 Chouser: but nice and general.

16:57 rzoom: a map of?

16:58 rzoom: e.g. {:a "3.5", :b "7"} would like to be able to convert :a value to float, and :b value to int

16:58 Chouser: rzoom: how do you decide what type to convert to?

16:59 rzoom: i can hard-code that

16:59 all :a's are going to be floats, all :b's ints, etc.

16:59 Chouser: {:a (Float. (:a mymap)), :b (Integer. (:b mymap))}

17:00 rzoom: so, i thought about a function to take a value and a type and return the converted value, then assoc new value

17:01 hiredman: (update-in map [:a] #(Float. %))

17:01 ,(-> {:a "3.5", :b "7"} (update-in [:a] #(Float. %)) (update-in [:b] #(Integer. %)))

17:01 clojurebot: {:a 3.5, :b 7}

17:01 kotarak: Float. not problematic? I though there was some Float/parseFloat or something, which was preferred.

17:02 rzoom: hiredman: that is pretty good.

17:03 * kotarak misses update...

17:04 kotarak: (w/o in)

17:05 Chouser: ,(into {} (for [[k v] {:a "3.5", :b "7"}] [k (({:a #(Float. %), :b #(Integer. %)} k) v)]))

17:05 clojurebot: {:b 7, :a 3.5}

17:06 rzoom: hmmmm. i guess that the best way to pass a class is just to do the Reflector call

17:06 the trouble being that there are a lot of keys, so being able to pass a list of keys to convert would be prettier.

17:07 Chouser: If all you're using the class for is to construct it, I'd recommend looking at passing around clojure fns instead, as both hiredman and I demonstrated.

17:07 hiredman: make a multimethod

17:07 rzoom: yeah, that is probably a good idea, will go with fn passing.

17:07 Chouser: That lets you use a static factory method instead, or constructor, or whatever. Plus it'll run faster that the reflector call.

17:07 than

17:09 hiredman: you can make a multimethod that dispatches on (fn [[a]] a) and map it over your map and then pour the resulting seq back into a map with into

17:16 replaca: rhickey: so where do contrib commits go now? github, svn, please wait, or other?

17:16 Chouser: where 'last' is defined in core.clj, there's no math yet. 'dec' isn't defined.

17:18 kotarak: So was git chosen?

17:21 replaca: kotarak: seems like we're almost there, if not quite. Last I heard, it was all still "experimental"

17:22 kotarak: replaca: well, I hoped for hg, but with hg-git it will hopefully work...

17:33 replaca: kotarak: yeah, I didn't have much opinion, but I'm used to git so it's pretty good by me (one less thing to learn :-)). I've tried git on windows (a little) this week and it seems to be not too bad

17:35 kotarak: replaca: I don't really care, I prefer hg mostly for philosophical reasons. I don't think there is much difference. hg or git don't buy each other much. And with hg-git by the github guys there's a bridge between the worlds. :)

17:36 technomancy: kotarak: yeah, nice timing on that.

17:38 bhurt: Having worked with both git and hg now, I think git is somewhat better for open source style development, but hg is better for a more centralized/corporate environment.

17:38 I HATE HATE HATE bazaar.

18:09 rhickey: first commit to github! http://github.com/richhickey/clojure/tree/master

18:11 liebke: woot! I saw the tweet :)

18:11 rhickey: just need to coordinate the move for contrib - any contribbers on?

18:12 * technomancy does a little jig

18:15 rhickey: hrm, I can't admin the clojure-contrib on github until I've imported the repo? I'd like to add collaborators who could help with that...

18:16 technomancy: you can create a blank repo and push to it after the fact.

18:16 rhickey: I want to use their svn import, a one-time thing

18:16 technomancy: oh, server-side import, right. I don't know about that.

18:17 rhickey: ah, direct url works

18:23 arohner: is it possible to call apply on a java method?

18:23 i.e. (apply .foo instance args)?

18:24 rhickey: arohner: no, Java methods are not proper functions

18:24 kotarak: arohner: http://paste.lisp.org/display/67182 by rhickey

18:25 arohner: excellent! thanks

18:27 replaca: rhickey: my idea about how to freeze: just tell us to stop for a day or so. Stephen and Stuart S. have been the big committers the last week or so.

18:29 bbl

19:37 mrsolo: http://paste.lisp.org/display/81782 any better way to do this? I found out that assoc is the only way to retain original comparator for sortedhash

19:38 Chousuke: mrsolo: wouldn't (into cur-result (...)) work?

19:39 mrsolo: no

19:39 will it?

19:39 hmm

19:39 let me try

19:39 i was doing (into {}

19:40 kotarak: and (apply assoc cur-result ...), partial is not needed

19:42 mrsolo: chousuke: oh yea it works thanks :-)

19:42 kotarak: you right...nice to know

19:43 kotarak: also nice idiom: (into (empty foo) ...)

19:43 Chousuke: yeah. preserves the type

19:44 kotarak: mrsolo: well you do it in your anon fn: (apply generate-tree (second x) more)

19:44 mrsolo: http://paste.lisp.org/display/81783 alternative form,

19:45 kotarak: ya my concept isn't that strong yet..need reiforcements :-)

19:45 nice empty is very handy

19:58 ack empty doesn't peserve comparator

19:59 http://paste.lisp.org/display/81786

20:18 Chouser: mrsolo: that's a sorted map?

20:19 sorted-map-by?

20:20 sure enough. probably counts as a bug.

20:22 mrsolo: ya sorted map

20:51 JAS4151: I'm not sure how to word my question, but I made a 'stateful' generator in clojure using lazy sequences and atoms to calculate the Fibonacci sequence, (here http://paste.lisp.org/display/81789#1 ... the fib-seq function... don't execute int he repl as it will just go on forever and crash clojure... use with take-n or something), is there an easier way to do this in Clojure? I know that in Common Lisp I would use variable capture instead of usi

20:54 stuhood: there is a definitely an easier

20:54 way

20:56 JAS4151: cool

20:56 stuhood: check out the functions "lazy-seq-fibo" and "fibo" from the Programming Clojure example code: http://github.com/stuarthalloway/programming-clojure/blob/cb0944e31490c0198a1ad2761b08a379fa73f480/examples/functional.clj

20:58 JAS4151: ok thanks, i'll look over these

21:00 ah so clojure works like erlang and you can match against number of arguments?

21:00 that's cool

21:04 stuhood: yea... pretty handy

21:05 you can also do destructuring in function arguments, which is similar to pattern matching, but not quite as powerful

21:10 JAS4151: i was reading about that, looks like it might be more useful than destructing-bind in common lisp

21:55 Chouser__: I cloned the clojure git repo, but it doesn't seem to have any branches in it. What did I do wrong?

21:57 arbscht: other than master, you mean?

21:59 Chouser__: yeah

21:59 I want 1.0 as well

21:59 arbscht: try git branch -a

21:59 you should be able to checkout 1.0 from origin

22:00 Chouser__: gah

22:00 yes, that did it, thanks.

22:00 I thought just "git branch" would show them all.

22:01 arbscht: that shows local branches only

22:01 make a local tracking branch if you want to modify 1.0

22:01 git checkout -b clojure-1.0 origin/clojure-1.0

22:01 Chouser__: wow. Guess I need to read up more on git.

22:02 my git-svn habits aren't sufficient. :-)

22:02 arbscht: heh :)

22:49 gstamp: Is there a function for replacing the nth element of a collection?

22:58 gnuvince_: (doc update-in)

22:58 clojurebot: "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."

22:58 gnuvince_: ,(update-in [1,2,3] [0] inc)

22:58 clojurebot: [2 2 3]

22:58 gnuvince_: ,(update-in [1,2,3] [0] (fn [] 17))

22:58 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2656$fn

22:58 gnuvince_: ,(update-in [1,2,3] [0] (fn [_] 17))

22:58 clojurebot: [17 2 3]

22:59 gnuvince_: Not terribly sexy I'm afraid

22:59 gstamp: yeah... should do the job. i'll wrap the non sexyness in a method to hide it.

22:59 thanks

23:00 gnuvince_: happy to ablige

23:02 cark: ,(assoc [0 1 2] 1 :a)

23:02 clojurebot: [0 :a 2]

23:06 gstamp: that's nicer. Neither seems to work for sequences though

23:06 lists rather

23:07 cark: rhikey doesn't like to provide core function doing the work in O(n)

23:07 maybe check seq-utils ?

23:08 gstamp: i'll check it out

23:08 hiredman: ,(let [a '(1 2 3)] (concat (take 1 a) [4] (drop 2 a)))

23:08 clojurebot: (1 4 3)

23:09 cark: that's ugly too =P

23:10 hiredman: it's lazy

23:11 gstamp: i should probably just ensure I'm always working with a vector

23:11 cark: yes, use the right data structure for the job

Logging service provided by n01se.net