#clojure log - May 13 2011

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

0:00 cemerick: sorry, I meant (derive :z :a), (derive :z :b), and (ancestors :z)

0:02 symbole: cemerick: I can see how libraries would just clobber their hierarchies. I think originally I thought about a situation where the parameter to a function is something like {:type ::dog}, and the dispatching function is :type, then because ::dog would be passed from a different library, it wouldn't find the correct method. It's a silly example though.

0:02 parameter to a method*

0:05 cemerick: symbole: FWIW, that's totally doable -- ::dog is just sugar for :*ns*/dog; you can just as easily name keywords in non-*ns* namespaces, e.g. :some.namespace/dog

0:07 symbole: I see. So as long as I pick a namespace I know nobody else will touch, I should be OK.

0:07 cemerick: right, which the ::dog syntax neatly provides

0:07 that doesn't guarantee that some other namespace won't clobber your hierarchy, but that just wouldn't be friendly.

0:08 The offending author would surely be chased with pitchforks and rotten fruit or something.

0:08 symbole: I understand. Thanks.

0:43 mrnex2010: im trying to make a macro so i can do (sh ls) (not having to use "" arround every argument, but im not getting a way to splice and put a ' before all the arguments so i can map str them, could anyone point me in?

1:05 markoman: has anyone made a pager with clojure? paginating results in html format like: << 1 2 3 ... >>

1:05 amalloy: mrnex2010: you could do it the way you describe with `(apply sh (map str '~@args)), but it's simpler to map to str while you're in macro-land: `(sh ~@(map str args))

1:09 er, and i guess the first version doesn't want an @

1:10 tomoj: I thought so too, but doesn't it?

1:10 oh.. no

4:15 lenw: hi all

4:17 does anyone know why you cant put a promise in a map ?

4:18 well i can put it in but i get a deadlock trying to get it out ?

4:18 is that the expected behaviour ?

4:19 Kneferilis: Hello!

4:19 Does clojure has a rich set of libraries like Common lisp?

4:21 amalloy: lenw: the deadlock is not in getting it out, but in printing it

4:22 Chousuke: Kneferilis: everything on the JVM is available

4:22 amalloy: &(let [m {1 (promise)}] (get m 1) nil)

4:22 sexpbot: ⟹ nil

4:22 Kneferilis: Chousuke: ok, but clojure doesn't have its own libraries?

4:22 Chousuke: Kneferilis: "own" as in?

4:23 amalloy: no, nobody has ever written any software in clojure

4:23 Chousuke: :P

4:23 lenw: thanks amalloy

4:23 Chousuke: Kneferilis: there are several libraries written in Clojure.

4:23 Kneferilis: Chousuke: well, own as in just like Java has its libraries

4:24 Chousuke: Kneferilis: on top of that, everything the JVM has.

4:24 which should be enough for anything :P

4:24 Kneferilis: Chousuke: where can I find these libraries?

4:24 Chousuke: google?

4:24 many are hosted on github, I guess you could search there by language

4:24 amalloy: Chousuke: clojars

4:25 Chousuke: oh right, that too.

4:25 amalloy: Kneferilis: seriously it's not clear what you're looking for. java is a programming language, in which people have written programs. some of those programs have reusable pieces, and you might choose to call them libraries. clojure is also a programming language, to which the same statements apply

4:25 clgv: Kneferilis: I think you should first know what you are looking for^^ searching for clojure libraries in general sounds strange

4:25 * clgv is going to search for prolog libraries :P

4:25 amalloy: clgv: prolog libraries...IN CLOJURE

4:26 Kneferilis: hmm

4:26 ok, thanks

4:27 * clgv reconsiders and is going to search for F# libraries :P ;)

4:27 * amalloy is going to search for BED. night, folks

4:28 clgv: night^^

4:28 * clgv checks his clock and notices that it's almost time for lunch

4:36 markoman: has anyone made a pager with clojure? paginating results in html format like: << 1 2 3 ... >>

4:36 clgv: does anyone know if I can start a counterclockwise nrepl on another computer and connect to it?

4:38 thorwil: markoman: yes

4:39 markoman: actually, i just went with "Newer" and "Older"

4:43 markoman: thorwill, do you have any example code to share, is it general to be applicaple to any vector / list of items?

4:44 thorwil: markoman: part of that code is appengine specific

4:45 markoman: Id like to have some features like max rows for paginating and sort functionality for created table too. Im using this for appengine too

4:46 thorwil: markoman: but you just need model functions to retrieve a range of items (instead of all of a kind), along with data for the pagination

4:46 markoman: ok, let me collect and pastebin something

4:46 markoman: could you just pass range to the query?

4:46 * thorwil has to reconsider using a private repo for everything

4:49 markoman: im using public github, but thinking when its necessary to pay a little and get private repos too...

4:51 thorwil: markoman: http://paste.pocoo.org/show/387974/

4:52 markoman: bitbucket.org allow private repos at no fee, but it's mercurial, not git

4:52 markoman: good to know

4:56 thorwil: very relevant code for me, thanks a lot

4:56 what this function does: process-fn

4:57 thorwil: markoman: i have some items to be listed that need no further processing. for that i pass identity to process-fn

4:57 markoman: and you are using enlive for html generation?

4:58 thorwil: markoman: but the body text of articles need to be changed from Text class to string for my views, so i pass a function as process-fn for that

4:59 markoman: yes. i like html templates that have no logic and no specific hooks in them

5:00 markoman: yes, I was operating with Text objects yesterday. they are not indexed and I concluded I cant make searches to those fields, right?

5:01 thorwil: right. i only know that if you want some kind of full text search, the common answer starts with lucene

5:03 markoman: I was thinking if there is any effiecient way to make searches on collection of text data, regex, or anything... first pulling data from datastore and then iterate each text field and search match... but it can be unefficient, if there are thousands up to million of records

5:03 what do you think?

5:06 thorwil: i don't know enough about it to say anything

5:07 markoman: k, need to make some test. about your code: how the last macro works, what id the functionality of it? other part of the code makes sense to me :)

5:07 id=is

5:08 thorwil: markoman: it just saves me some typing, as all my views are defined like (view-pipe journal ...

5:09 markoman: with html templates. in my case i found, that i need to alter class and ids attributes on tags so often, that html templates would have been less use. so I like hiccup over templates in this case

5:10 thorwil: markoman: that is, the arguments to a view are threaded through a number of functions and finally response-shell, which is an enlive template with the base html skeletion, wrapped as response

5:12 clgv: I have several big computers available where I want to run my clojure program on large problem instances. is there an easy way to get it running overthere with let's say a couple commands typed in a local repl?

5:17 markoman: thorwil: ok, I think I understand in general state what is does. so far I havent used too much time with layout. maybe I'm facing this bit later and need some more guidance

5:18 thorwil: ok

5:19 markoman: thanks, I think I got necessary confirmation how paging should be done

5:21 thorwil: np

6:15 Kneferilis: is clojars compatible with clogure for .NET?

6:16 shanmu: Hi, Is there a clojure.contrib.logging version for 1.3? When I try to user c.c.logging with clojure 1.3 I end up with warning related to global vars not being dynamic...

6:16 clgv: Kneferilis: clojars is a repository for clojure jar files afaik and you can't load jars in .NET last time I checked.

6:20 raek: shanmu: c.c.logging has become a "new contrib" project, so you can use [org.clojure/tools.logging "0.1.2"] now

6:20 Kneferilis: you can convert jar files into dlls with IKVM

6:20 raek: shanmu: it should work for both 1.2 and 1.3

6:21 Kneferilis: clgv: ^^

6:21 clgv: you can convert jar files into dlls with IKVM

6:22 clgv: Kneferilis: that would be kinda hacky I guess. If I were you, I would get the clojure source and compile it with ClojureCLR if there is nothing compiled yet for the project in question

6:23 raek: shanmu: project page with docs is here: https://github.com/clojure/tools.logging

6:27 shanmu: raek: thanks! I searched a bit but could not find this page... :)

7:11 clgv: I have resources in a special subdirectory/namespace ,e.g. "bla/blubb" - how can I list all resources in that directory?

7:12 fliebel: clgv: file-seq? ls -R?

7:12 clgv: oh I forgot. It's all in a jar...

7:12 fliebel: clgv: (file-seq (File. "jar://resources))

7:17 clgv: (-> (File. "jar://spec/algo") .exists) returns false ;(

7:17 I know it is there

7:19 I get the following when I enter one explicit resource file #<URL jar:file:/home/me/standalone.jar!/spec/algo/config.clj>

7:20 I did (resource "/spec/algo/config.clj")

7:20 fliebel: hm, weird, you might have to google the syntax for targeting the jar.

7:20 clgv: hm probably^^ I thought resource might be the key

8:57 hm damn. I need a transparent way to load these resources no matter if I am in a normal clojure REPL or in a jar execution. I need to load all files within a certain resource directory/namespace.

9:04 chouser: clgv: clojure.java.io/resource

9:05 clgv: chouser: the problem is that I don't know in advance how much files might be there

9:06 that means I need to iterate over all the files that are in there. one first step could be to be able to list all resouces in a directory/namespace

9:09 stuartsierra: clgv: https://github.com/clojure/java.classpath may help

9:11 clgv: stuartsierra: it seems it might. thx. :D

9:12 stuartsierra: is it already part of clojure or contrib?

9:13 hm seems not

9:14 stuartsierra: "contrib" is no longer a single thing

9:14 clgv: hm true. but I am still used to the 1.2.0 standalone thingy

9:15 stuartsierra: You can use org.clojure : java.classpath : 0.1.1 in a project

9:15 an older version of java.classpath is available in clojure-contrib 1.2.0

9:16 clgv: yeah the older one only has 3 basic functions available ;)

9:19 stuartsierra: what would be the most elegant way to find out whether the program is running in a jar or not

9:22 stuartsierra: clgv: search for the resource of the main class file, examine the URL to see if it's in a JAR

9:22 raek: clgv: iirc, Leiningen can browse the classpath for .clj files in the leiningen/ directory to find hooks. this feature is not enabled by default, but it should be in the source somewhere

9:23 so maybe that could be worth investigating

9:23 clgv: stuartsierra: sounds good

9:30 this jar vs non-jar business is really ugly. :(

9:31 stuartsierra: It's not supposed to matter.

9:32 clgv: in general not. but when you want to list resources then it does

9:40 $findfn "java/net/URL" "java.net.URL"

9:40 sexpbot: []

9:40 clgv: ok regexp replace then...

9:40 raek: doesn't look like java provides a simple way to do it... http://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory

9:42 PathMatchingResourcePatternResolver from Spring seems to do it

9:44 clgv: raek: thanks for looking it up but I dont really want a spring dependency ;)

9:52 mprentice: opinion question: better to use "2" or "to" in project name? like ps2pdf or pstopdf?

9:54 dpritchett`: I'd probably choose some obscure pop culture reference instead.

9:54 clgv: how about camelcase? :P

9:54 wastrel: i like ps2pdf

9:54 camelcase is evil for cli

9:55 mprentice: it's just a program to convert from one data format to another

9:55 clgv: lol hence the smiley ;)

10:02 hmmm (use 'my.ns) does behave different in the REPL depending on whether the file is in the "src" or "resources" directory. this can only be a classpath issue, can't it?

10:03 hm but "resources" is on the classpath in that REPL instance

10:05 or a dumb renaming error, lol. :(

10:14 raek: clgv: I have noticed that when I create the resources/ directory after starting the clojure instance, I can't access the resources in there. (a restart is needed.) dunno if this was what happened to you, though... :)

10:15 clgv: no. I renamed the file and forgot to rename the namespace but I didn't get it from the error message immediately

10:31 dnolen: atoms are fast

10:33 stuartsierra: yes, they are basically java.util.concurrent.atomic.AtomicReference

10:39 * ilyak does cargo cult macro writing

10:40 ilyak: keep adding funny characters to macro until it works

10:40 `:'#~@

10:41 fliebel: &`''test

10:41 sexpbot: ⟹ (quote (quote clojure.core/test))

10:41 jarpiain: ,'~@`#'+

10:41 clojurebot: (clojure.core/unquote-splicing (clojure.core/seq (clojure.core/concat (clojure.core/list (quote var)) (clojure.core/list (quote clojure.core/+)))))

10:41 fliebel: jarpiain: Hey, your wrote that clojure in clojure compiler, right?

10:42 jarpiain: yeah, still missing some special forms

10:43 fliebel: jarpiain: I was wondering how this relates to the 'official' Clojure compiler, and if there is any chance of this becoming the new compiler, or if this is just a hobby of yours.

10:45 jarpiain: no official word but it's there if anyone wants it

10:46 fliebel: jarpiain: Have you tried persuading rich or someone else form the core team?

10:46 dnolen: jarpiain: you based your work on the current Java code? I note that the Java code leans on Clojure data structures so it seems rhickey has been thinking about the eventual translation.

10:49 stuartsierra: Speaking for the Clojure/core team, we've been focused on fixing bugs & improving the existing compiler. Clojure-in-Clojure is a more distant goal.

10:50 jarpiain: dnolen: it's a monadic translation of clojure.lang.Compiler

10:50 depends on c.l.Reflector, should use clojure.reflect instead to get a sane implementation of deftype and reify

10:51 dnolen: jarpiain: interesting. I chatted with rhickey at the last NYC Clojure Meetup and it seemed like he has some new ideas about the compiler, he didn't go into the details of course.

10:52 fliebel: sad panda, I saw a lot of cool stuff with the status "Waiting one new compiler", as well as some people wanting to port Clojure to new places as soon as cinc comes around.

10:53 TimMc: Would the goal be to get a completely self-hosted Clojure?

10:54 clgv: is there are shortcut to create a regexp from a string on runtime?

10:54 manutter: ,(doc re-pattern)

10:54 clojurebot: "([s]); Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher."

10:54 clgv: ah thanks :)

10:54 manutter: np

10:54 stuartsierra: TimMc: I think the goal would be to abstract away the specifics of the Java implementation, to make porting easier.

10:54 clgv: $findfn "bla" #"bla"

10:54 sexpbot: []

10:55 clgv: sxpbot couldnt have done it it seems ;)

10:55 gfrlog: ,(re-pattern "bla")

10:55 clojurebot: #"bla"

10:55 jarpiain: (= #"bla" #"bla")

10:55 gfrlog: (= #"bla" (re-pattern "bla"))

10:55 jarpiain: ,(= #"bla" #"bla")

10:55 clojurebot: false

10:56 gfrlog: well that's it

10:56 ,({#"well" "haha"} #"well")

10:56 clojurebot: nil

10:56 clgv: ah kk^^

10:56 gfrlog: I guess I should stop using regexes as keys in my maps

10:58 Fossi: -_-

11:00 gfrlog: (defn unapply [f & args] (f args))

11:02 clgv: lol

11:14 S11001001: gfrlog: you mean funcall surely

11:14 oh I can't read never mind

11:15 mabes: does anyone know enough about the internals of protocols to say how easy it would be to memoize a protocol function? Meaning, I want all of the implementations of a certain protocol function to be memoized

11:18 chouser: mabes: a protocol function *is* a function, so memoize can be used just as it would be on any function

11:19 mabes: chouser: sure, but I want to apply the memorization to all the functions not just a record's specific implementation of it

11:19 chouser: I believe there is call-site caching that is normally done on protocol call-sites which would likely be thwarted by memoize, so I don't know what the performance impact would be.

11:20 mabes: (defprotocol P (pf [_])) (def pf2 (memoize pf))

11:20 every call to pf2 will be memoized, regardless of the specific implementation of pf

11:21 mabes: chouser: yeah, that is what I'm doing now (but with a different version of memoize)... I would prefer not to use a different name though

11:24 gfrlog: mabes: that sounds fundamentally impossible to me, in the same way that in Java it would be impossible to have an interface cause all implementations to be meoized

11:24 s/meoized/memoized

11:24 sexpbot: <gfrlog> mabes: that sounds fundamentally impossible to me, in the same way that in Java it would be impossible to have an interface cause all implementations to be memoized

11:25 gfrlog: I mean I could imagine protocols being implemented in a way that would allow that, but I doubt they were...

11:26 mabes: I figured it out

11:27 gfrlog: yeah?

11:27 chouser: oh, I suppose you can (def pf (memoize pf)), but I don't think I'd recommend it

11:28 devn: so if im using 1.3.0-master-SNAPSHOT, what's the "right" way to use contrib?

11:29 mabes: chouser: heh, that that is what I just did :)

11:29 (defprotocol P (pf [_])) (def uncached-pf pf) (defrecord Foo [x] P (pf [_] (println "I am being called.") (inc x))) (def pf (memoize uncached-pf)) (pf (Foo. 5)) (pf (Foo. 5))

11:30 chouser: what are the potential issues with the above approach?

11:31 chouser: oh, storing the original off to the side like that is probably a bit better than losing it entirely

11:31 the only remaining problem I can think of is the performance issue I mentioned earlier.

11:33 fogus`: The reason to use memoization in the first place is to gain some performance no? Maybe it's a wash.

11:33 mabes: Yeah, the fastest approach would probably be to duplicate the memoization call in each of the record's version...

11:33 fliebel: I think extend takes actual fn objects, so you could write the record empty, and extend the memoized fns onto it.

11:34 chouser: if the implementations are really slow and the function is call relatively infrequently, I can imagine the memoize could be a big win

11:34 mabes: yeah, for my purposes I think the above makes the most sense.. that way I don't have to worry about new records not implementing memoize (which is central to the function still my memoize spills over to disk for persistence)

11:34 fogus`: (inc fliebel)

11:34 sexpbot: ⟹ 3

11:35 mabes: chouser: my function in question can take up to several hours :)

11:35 chouser: heh, right, so the inlining of the call really isn't going to help

11:35 fogus`: mabes: I'm not sure that call-site caching helps ;-)

11:35 chouser: you might consider multimethods for a situation like that.

11:35 ilyak: Hi *

11:36 mabes: thanks all for the feedback and help

11:36 chouser: mabes: do your impementations call themselves at all?

11:36 ilyak: What's the best way to implement this: I have a callback interface (hibernate's Work) which I would proxy with a function that computes a value, and then I need to return that value

11:36 Problem is, Work's callback method returns void

11:37 chouser: ilyak: Ugh. Shared mutable state.

11:37 ilyak: So I need to stash that value in some kind of mutable (or final as in settable-once) container

11:37 mabes: chouser: they will call the same function on different records internally

11:37 ilyak: and then return it

11:37 What's the best primitive to use?

11:37 ref? atom? something else?

11:37 chouser: It would be pure if not for void return type

11:38 chouser: mabes: be careful then that they're calling the memoized version (assuming that's what you want)

11:38 mabes: chouser: good point, let me verify that it works as I expect...

11:38 chouser: ilyak: right, I'm saying that api is forcing you to use shared mutable state. An atom or a promise might work well enough.

11:40 mabes: ilyak: probably stick an atom in your proxy object and deref it once it is done. I don't fully understand what you need to do though, so that may not apply...

11:41 ilyak: mabes: see hibernate's Work class

11:41 I need to compute some value in its only method and then use it somewhere

11:42 which is tricky since it returns void

11:42 s/class/interface

11:42 dnolen: fogus`: I replied on the ML, were there specific questions you had?

11:42 fogus`: dnolen: Probably. I will read what you have after lunch and try to articulate myself.

11:43 dakrone: dnolen: are you going to be publishing design stuff to a wiki somewhere?

11:43 mabes: ilyak: this class? http://docs.jboss.org/hibernate/core/3.5/api/

11:43 ilyak: er... frames.. one sec

11:44 ilyak: this one? http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/jdbc/Work.html

11:45 dnolen: dakrone: I suppose, but at this point it's all skunk work. it's why I'm trying to get people to read the papers. Then we can agree upon a good approach.

11:45 dakrone: dnolen: I shall read the papers first then

11:46 mabes: does reify replace proxy or is proxy still the preferred function for creating on-the-fly java classes/instances?

11:47 (I know reify is used for anonymous protocol impls)

11:47 chouser: mabes: reify is better when you can use it, but refuses to extend concrete classes

11:47 mabes: ah, makes sense

11:47 chouser: it's not uncommon for me to switch back and forth in a single use case as I need to / stop needing to extend a concrete class

11:48 which is a pain since the syntax is different. :-P

11:48 KirinDave: chouser: I hope moving forward that particular problem is fixed.

11:48 chouser: but I have a macro that lets you use reify-style syntax for a proxy, in case that's helpful.

11:48 KirinDave: chouser: Most everyone I've talked to so far ends up writing elaborate macros to avoid dealing with it.

11:49 chouser: yeah

11:49 KirinDave: chouser: (as well as to avoid dealing with the static-dynamic divide)

11:49 chouser: https://gist.github.com/871513

11:50 KirinDave: Indeed

11:50 Not an unfamiliar pattern to me.

11:56 dnolen: chouser: huh, you find yourself wanting to use reify to extend a concrete class? or just that you want a new feature - something like proxy w/ reify syntax.

11:57 chouser: I find I need an implementation of an interface, so I use reify. Then later I discover it must also extend a concrete class, but switching to proxy requires touching almost every line of code in the reify.

11:57 just a simple syntactic problem

11:59 proxy's syntax is poor because it captures 'this' and now is out of date because it's dissimilar to reify/defrecord/deftype/extend

12:00 gfrlog: there aren't any conventional semantics for vars that begin with dollar-signs are there?

12:01 (I noticed incanter using one)

12:03 mabes: gfrlog: not that I know of.. I think incacnter's use is more JS inspired.. (e.g. the do everything operator :) )

12:03 gfrlog: very good

12:04 mabes: chouser: btw, memoization seems to work fine with the impls calling other versions of the function: https://gist.github.com/970804 I'll keep an eye out for potential issues though

12:05 hmm.. actually, that is not testing what I wanted to test.. hang on

12:10 yeah, it still works as expected: https://gist.github.com/970804

12:11 Kneferilis: Hello!

12:11 any programmers of clojure .NET?

12:19 dnolen: Kneferilis: there a couple, might be easier to ping the mailing list if you have a specific question.

12:20 Kneferilis: dnolen: I see, thanks.

12:25 mprentice: i would like to disable xml validation. i found http://www.paullegato.com/blog/dtd-validation-malformed-xml-clojure/ is that the right way to do it?

13:15 Kneferilis: Hello!

13:16 how do I find information on the clojar libraries?

13:16 vinzent_: clojars.org? or what do you mean

13:17 manutter: have a look at http://www.clojure-toolbox.com/

13:17 amalloy: (inc manutter)

13:17 sexpbot: ⟹ 1

13:17 manutter: It's not strictly a guide to clojars, but it's a good ref

13:17 lol, tks sexpbot :)

13:17 amalloy: there's another site a lot like that one, but i forget what it's called

13:17 vinzent_: manutter, cool, thanks for the link

13:18 manutter: np. There's some library info at clojuredocs .org too

13:19 Kneferilis: manutter: thanks

13:58 ilyak: ,(use clojure.set :as sets)

13:58 clojurebot: java.lang.ClassNotFoundException: clojure.set

13:58 ilyak: why?

13:58 clojurebot: http://clojure.org/rationale

13:58 stuartsierra: ilyak: you need (use '[clojure.set :as sets])

13:59 dnolen: nice literal support for deftype/record in master

14:02 vinzent_: I've got Failed to load Main-Class manifest attribute from... when trying to java -jar my-uber.jar. :aot are ok and :gen-class is present. What am I doing wrong?

14:02 TimMc: dnolen: Yeah?

14:02 dnolen: TimMc: yup.

14:03 TimMc: OK, I'll look it up for myself.

14:03 fliebel: dnolen: Link? What does it look like? Just #=(foo 1 2 3)?

14:03 Are constructors implemented as well already?

14:03 dnolen: #user.A[nil, nil] for type, #user.B{:a nil, :b nil} for record.

14:05 fliebel: Hm, same thing of course. I was thinking functions where going to be created for constructors, like (foo: 1 2 3)

14:05 TimMc: dnolen: So, namespace-qualified names are required?

14:05 fogus`lunch: defrecords allow both forms

14:17 dnolen: TimMc: as far I can tell yes.

14:17 fliebel: I don't see auto-generated ctors.

14:18 fogus`: ctors?

14:19 dnolen: fogus: sorry i mean constructor fns.

14:19 fliebel: dnolen: I guess literals kind of offer the same functionality, right?

14:19 fogus`: I see. For defrecords 2 are generated map->R and ->R and for types only ->T

14:20 dnolen: fogus`: whoa, sweet

14:22 chouser: I guess if we're going to have new names being auto-defined, having them look like syntax is better than not.

14:23 fliebel: Yea, it's kind of confusing if you ask me, having #foo.Bar[1 2 3] and (->Bar 1 2 3)

14:24 hiredman: fliebel: one is run by the reader, the other is a function call

14:24 it's like ^ vs. with-meta

14:25 fliebel: right

14:25 stuartsierra: Clojure 1.3.0-alpha7 is out the door with these additions.

14:26 amalloy: stuartsierra: i don't know how to navigate jira. is http://dev.clojure.org/jira/browse/CLJ-426 included in that alpha?

14:27 alandipert: amalloy: yes that's in

14:28 fliebel: stuartsierra: As of, now?

14:29 amalloy: thanks alandipert

14:29 stuartsierra: as of, seconds ago

14:30 fliebel: wee :)

14:32 rlb: is there an idiom I'm not thinking of for creating something like a recursive with-foo, where only the top-level actually closes/disconnects/whatever?

14:32 I can think of ways to do it, but so far they're not as clean as I'd like.

14:33 stuartsierra: rlb: Scopes! (which don't exist yet)

14:33 We've spent a lot of time talking about this problem, but never came up with a clean solution either.

14:34 rlb: Dynamic binding is the tool for doing things like this.

14:35 rlb: stuartsierra: assuming you mean (binding ...), then right, but (as you probably assumed) I need per-context counting.

14:36 hiredman: (binding [*foo* (or *foo* (new-foo))] ...)

14:36 rlb: hiredman: sure, but what if I have a nested with-foo for some other resource.

14:36 stuartsierra: yes, or make the thing you bind a stack or a counter

14:36 rlb: i.e. the *foo* needs to be more like macro scoping.

14:37 (that didn't make sense...)

14:37 hiredman: rlb: I am very aware that it didn't

14:37 rlb: anyway -- I probably just need to track the counter in the param...

14:37 stuartsierra: (binding [*foo* (cons (new-foo) *foo*)] …)

14:37 dnolen: fogus`: there no new reflection stuff on types/records is there?

14:38 rlb: hiredman: wrt not making sense, I meant me (in case it wasn't clear).

14:40 fogus`: dnolen: What did you have in mind?

14:41 hiredman: rlb: it was

14:41 rlb: stuartsierra: fwiw, more specifically, I was thinking about something like (with-expensive-connection c ...) and wanted it to just leave c alone, except at the top-level, where c would be disconnected.

14:42 * fogus` writes tests that make Rich put his head in his hands

14:42 stuartsierra: rlb: you can do that with `binding` and a counter.

14:42 dnolen: fogus`: pattern matching of course, seems like literals should be allow for matching.

14:43 fogus`: stuartsierra: are these literals supported in case as well?

14:43 stuartsierra: I'm guessing not, since they're not compile-time constants.

14:43 Kneferilis: hi

14:44 hiredman: stuartsierra: aren't they? by the time the compile compiles the case statement the read has created the record, no?

14:45 compiler

14:45 reader

14:45 stuartsierra: dunno

14:45 fogus`: Yeah, the result of the literal is a record

14:45 (let [{a :a} #user.R[42]] #{a}) => #{42}

14:46 hiredman: thats kind of what 'literal' means, yes? created by the reader

14:46 fogus`: (let [r #user.R[42]] (case r nil :foo #user.R[42] :yay)) => :yay

14:47 hiredman: neato

14:47 stuartsierra: `case` just needs to be able to compute a hash code at compile time, so it should work.

14:48 fogus`: (into #user.R{} {:a 42 :b 108}) => #user.R{:a 42, :b 108}

14:48 rlb: stuartsierra: were you still talking about a stack too?

14:48 I was thinking about (with-conn c1 ... (with-conn c2 (foo c1))))

14:48 where foo also calls (with-conn c1) at some point.

14:48 jarpiain: how would (defrecord R [x y z] ... (foo [_] #user.R[1 2 3])) work then? (does it?)

14:49 stuartsierra: rlb: All you need there is a counter.

14:49 rlb: I need a counter for c1 and a counter for c2.

14:49 hiredman: jarpiain: can't work

14:49 fogus`: jarpiain: foo would return the same as (R. 1 2 3)

14:50 oh wait... I see

14:50 dakrone: stuartsierra: do you know how long it will be before alpha7 makes it to maven?

14:50 fogus`: foo is in the body of R

14:50 stuartsierra: dakrone: between 1 and 24 hours

14:50 dakrone: roger, thanks

14:52 fliebel: Do vectors have some super fast way of putting 2 together?

14:52 chouser: fliebel: into, O(m)

14:52 rlb: (and the with-conn in foo just needs to be able to find the count for c1)

14:53 fliebel: chouser: Weee :)

14:53 fogus`: jarpiain: hiredman is right... at that point it doesn't exit yet

14:53 dnolen: fogus`: ah, I see, case will work w/ records not types.

14:53 ilyak: Where can I read about clojure compiler syntax?

14:53 I want to integrate it into ant

14:54 How do I tell clojure compiler to compile all .clj files it finds in a tree starting with <dir>?

14:54 (as opposed to passing every single namespace)

14:55 chouser: fliebel: finger trees have an O(log n) concat. *shrug*

14:55 fliebel: chouser: Yea, they are awesome :)

15:07 rlb: stuartsierra: perhaps for light use:

15:07 (defmacro with-conn [c & forms]

15:07 `(if (contains? *connections* c) (do ~@forms) (try ...)))

15:07

15:08 And of course only within a single thread.

15:23 scgilardi: rlb: the definitions of with-connection* and transaction* in https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc/internal.clj include an example of nesting with a count and only doing significant work at the outermost level.

15:24 rlb: (btw my syntax was all wrong -- just starting to use clojure's defmacro -- mixed up ~ and #, etc.)

15:24 scgilardi: thanks

15:28 scgilardi: that looks similar to what I was thinking, though I've been using a set rather than a counter.

15:47 scgilardi: rlb, cool, yw

16:08 dnolen: clojure-mode needs fixin for deftype/record literal syntax...

16:37 amalloy: dnolen: good point. what have you noticed that breaks?

16:42 hugod: amalloy: did you get a chance to play with the swank-clj debugger?

16:50 amalloy: hugod: no, haven't done any clojure for a couple days. life getting in the way

16:51 hugod: :)

16:51 dnolen: amalloy: vectors and maps need to check that they aren't proceeded by literal record/type prefix

16:52 amalloy: dnolen: in what context? like, for syntax highlighting, sending to swank, or what?

16:53 dnolen: amalloy: correction, paredit needs to be tweaked it seems.

16:54 amalloy: really? i would have expected paredit to work fine. or do you hope it would treat a record literal as a single atom when doing eg C-M-f?

16:55 dnolen: amalloy: paredit want to put a space, "#user.A [^]", ^ is the cursor.

16:55 space between A and [

16:56 amalloy: aha

17:02 dnolen: i think i see a simple and not-very-hacky way to do that

17:03 dnolen: amalloy: cool!

17:03 amalloy: (save-excursion (backwards-sexp) (looking-at "#")) should tell us whether point is in or after a token starting with #

17:05 i guess you could add that as advice around one of the existing paredit functions just as a modification to your .emacs, maybe? would be nice not to have to change paredit. i'll go see what advice they have for me in #emacs

17:10 dnolen: ooc does that cause the reader to break, or just look ugly?

17:16 dnolen: amalloy: reader breaks, swank-clojure needs to be fixed as well.

17:16 #user.A[0 0]^, C-x C-e is broken

17:17 amalloy: dnolen: i assume it's just sending [0 0] though, because last-sexp isn't slurping it up

17:17 dnolen: amalloy: yup

17:18 amalloy: dnolen: does [#user.A[0 0]]^ work?

17:19 dnolen: amalloy: yes

17:20 amalloy: then swank probably doesn't need fixing, just slime

17:20 sadly i know a lot less about slime than paredit

17:30 dnolen: what if you highlight the #user.a[0 0] and M-x slime-eval-region? (also, i guess i have to start using 1.3 if i'm gonna work on this)

17:31 if that works, and i expect that it does, the best solution is probably to (1) patch paredit, (2) figure out how to hook into backward-sexp

18:02 mprentice: can i stop the thread started by clojure.contrib.lazy-xml/parse-trim ? it's staying open after i'm done with the file.

22:25 steven: hey guys

22:25 whats a better way of doing (rest (rest form))

22:26 assuming form is a list

22:33 tomoj: if you're OK with (next (next form)) instead there's nnext

22:38 steven: okay, thanks

22:42 tomoj: the only difference in the case of a list being that if the list has two elements it will return nil instead of ()

23:57 amalloy: $findfn [1 2 3 4] [3 4]

23:57 sexpbot: [clojure.core/nnext]

23:57 amalloy: steven: ^ can help

Logging service provided by n01se.net