#clojure logs

2011-05-13

00:00cemericksorry, I meant (derive :z :a), (derive :z :b), and (ancestors :z)
00:02symbolecemerick: 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.
00:02symboleparameter to a method*
00:05cemericksymbole: 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
00:07symboleI see. So as long as I pick a namespace I know nobody else will touch, I should be OK.
00:07cemerickright, which the ::dog syntax neatly provides
00:07cemerickthat doesn't guarantee that some other namespace won't clobber your hierarchy, but that just wouldn't be friendly.
00:08cemerickThe offending author would surely be chased with pitchforks and rotten fruit or something.
00:08symboleI understand. Thanks.
00:43mrnex2010im 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?
01:05markomanhas anyone made a pager with clojure? paginating results in html format like: << 1 2 3 ... >>
01:05amalloymrnex2010: 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))
01:09amalloyer, and i guess the first version doesn't want an @
01:10tomojI thought so too, but doesn't it?
01:10tomojoh.. no
04:15lenwhi all
04:17lenwdoes anyone know why you cant put a promise in a map ?
04:18lenwwell i can put it in but i get a deadlock trying to get it out ?
04:18lenwis that the expected behaviour ?
04:19KneferilisHello!
04:19KneferilisDoes clojure has a rich set of libraries like Common lisp?
04:21amalloylenw: the deadlock is not in getting it out, but in printing it
04:22ChousukeKneferilis: everything on the JVM is available
04:22amalloy&(let [m {1 (promise)}] (get m 1) nil)
04:22sexpbot⟹ nil
04:22KneferilisChousuke: ok, but clojure doesn't have its own libraries?
04:22ChousukeKneferilis: "own" as in?
04:23amalloyno, nobody has ever written any software in clojure
04:23Chousuke:P
04:23lenwthanks amalloy
04:23ChousukeKneferilis: there are several libraries written in Clojure.
04:23KneferilisChousuke: well, own as in just like Java has its libraries
04:24ChousukeKneferilis: on top of that, everything the JVM has.
04:24Chousukewhich should be enough for anything :P
04:24KneferilisChousuke: where can I find these libraries?
04:24Chousukegoogle?
04:24Chousukemany are hosted on github, I guess you could search there by language
04:24amalloyChousuke: clojars
04:25Chousukeoh right, that too.
04:25amalloyKneferilis: 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
04:25clgvKneferilis: I think you should first know what you are looking for^^ searching for clojure libraries in general sounds strange
04:25amalloyclgv: prolog libraries...IN CLOJURE
04:26Kneferilishmm
04:26Kneferilisok, thanks
04:28clgvnight^^
04:36markomanhas anyone made a pager with clojure? paginating results in html format like: << 1 2 3 ... >>
04:36clgvdoes anyone know if I can start a counterclockwise nrepl on another computer and connect to it?
04:38thorwilmarkoman: yes
04:39thorwilmarkoman: actually, i just went with "Newer" and "Older"
04:43markomanthorwill, do you have any example code to share, is it general to be applicaple to any vector / list of items?
04:44thorwilmarkoman: part of that code is appengine specific
04:45markomanId like to have some features like max rows for paginating and sort functionality for created table too. Im using this for appengine too
04:46thorwilmarkoman: but you just need model functions to retrieve a range of items (instead of all of a kind), along with data for the pagination
04:46thorwilmarkoman: ok, let me collect and pastebin something
04:46markomancould you just pass range to the query?
04:49markomanim using public github, but thinking when its necessary to pay a little and get private repos too...
04:51thorwilmarkoman: http://paste.pocoo.org/show/387974/
04:52thorwilmarkoman: bitbucket.org allow private repos at no fee, but it's mercurial, not git
04:52markomangood to know
04:56markomanthorwil: very relevant code for me, thanks a lot
04:56markomanwhat this function does: process-fn
04:57thorwilmarkoman: i have some items to be listed that need no further processing. for that i pass identity to process-fn
04:57markomanand you are using enlive for html generation?
04:58thorwilmarkoman: 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
04:59thorwilmarkoman: yes. i like html templates that have no logic and no specific hooks in them
05:00markomanyes, I was operating with Text objects yesterday. they are not indexed and I concluded I cant make searches to those fields, right?
05:01thorwilright. i only know that if you want some kind of full text search, the common answer starts with lucene
05:03markomanI 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
05:03markomanwhat do you think?
05:06thorwili don't know enough about it to say anything
05:07markomank, 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 :)
05:07markomanid=is
05:08thorwilmarkoman: it just saves me some typing, as all my views are defined like (view-pipe journal ...
05:09markomanwith 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
05:10thorwilmarkoman: 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
05:12clgvI 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?
05:17markomanthorwil: 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
05:18thorwilok
05:19markomanthanks, I think I got necessary confirmation how paging should be done
05:21thorwilnp
06:15Kneferilisis clojars compatible with clogure for .NET?
06:16shanmuHi, 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...
06:16clgvKneferilis: clojars is a repository for clojure jar files afaik and you can't load jars in .NET last time I checked.
06:20raekshanmu: c.c.logging has become a "new contrib" project, so you can use [org.clojure/tools.logging "0.1.2"] now
06:20Kneferilisyou can convert jar files into dlls with IKVM
06:20raekshanmu: it should work for both 1.2 and 1.3
06:21Kneferilisclgv: ^^
06:21Kneferilisclgv: you can convert jar files into dlls with IKVM
06:22clgvKneferilis: 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
06:23raekshanmu: project page with docs is here: https://github.com/clojure/tools.logging
06:27shanmuraek: thanks! I searched a bit but could not find this page... :)
07:11clgvI have resources in a special subdirectory/namespace ,e.g. "bla/blubb" - how can I list all resources in that directory?
07:12fliebelclgv: file-seq? ls -R?
07:12clgvoh I forgot. It's all in a jar...
07:12fliebelclgv: (file-seq (File. "jar://resources))
07:17clgv(-> (File. "jar://spec/algo") .exists) returns false ;(
07:17clgvI know it is there
07:19clgvI get the following when I enter one explicit resource file #<URL jar:file:/home/me/standalone.jar!/spec/algo/config.clj>
07:20clgvI did (resource "/spec/algo/config.clj")
07:20fliebelhm, weird, you might have to google the syntax for targeting the jar.
07:20clgvhm probably^^ I thought resource might be the key
08:57clgvhm 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.
09:04chouserclgv: clojure.java.io/resource
09:05clgvchouser: the problem is that I don't know in advance how much files might be there
09:06clgvthat 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
09:09stuartsierraclgv: https://github.com/clojure/java.classpath may help
09:11clgvstuartsierra: it seems it might. thx. :D
09:12clgvstuartsierra: is it already part of clojure or contrib?
09:13clgvhm seems not
09:14stuartsierra"contrib" is no longer a single thing
09:14clgvhm true. but I am still used to the 1.2.0 standalone thingy
09:15stuartsierraYou can use org.clojure : java.classpath : 0.1.1 in a project
09:15stuartsierraan older version of java.classpath is available in clojure-contrib 1.2.0
09:16clgvyeah the older one only has 3 basic functions available ;)
09:19clgvstuartsierra: what would be the most elegant way to find out whether the program is running in a jar or not
09:22stuartsierraclgv: search for the resource of the main class file, examine the URL to see if it's in a JAR
09:22raekclgv: 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
09:23raekso maybe that could be worth investigating
09:23clgvstuartsierra: sounds good
09:30clgvthis jar vs non-jar business is really ugly. :(
09:31stuartsierraIt's not supposed to matter.
09:32clgvin general not. but when you want to list resources then it does
09:40clgv$findfn "java/net/URL" "java.net.URL"
09:40sexpbot[]
09:40clgvok regexp replace then...
09:40raekdoesn't look like java provides a simple way to do it... http://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory
09:42raekPathMatchingResourcePatternResolver from Spring seems to do it
09:44clgvraek: thanks for looking it up but I dont really want a spring dependency ;)
09:52mprenticeopinion question: better to use "2" or "to" in project name? like ps2pdf or pstopdf?
09:54dpritchett`I'd probably choose some obscure pop culture reference instead.
09:54clgvhow about camelcase? :P
09:54wastreli like ps2pdf
09:54wastrelcamelcase is evil for cli
09:55mprenticeit's just a program to convert from one data format to another
09:55clgvlol hence the smiley ;)
10:02clgvhmmm (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:03clgvhm but "resources" is on the classpath in that REPL instance
10:05clgvor a dumb renaming error, lol. :(
10:14raekclgv: 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:15clgvno. I renamed the file and forgot to rename the namespace but I didn't get it from the error message immediately
10:31dnolenatoms are fast
10:33stuartsierrayes, they are basically java.util.concurrent.atomic.AtomicReference
10:40ilyakkeep adding funny characters to macro until it works
10:40ilyak`:'#~@
10:41fliebel&`''test
10:41sexpbot⟹ (quote (quote clojure.core/test))
10:41jarpiain,'~@`#'+
10:41clojurebot(clojure.core/unquote-splicing (clojure.core/seq (clojure.core/concat (clojure.core/list (quote var)) (clojure.core/list (quote clojure.core/+)))))
10:41fliebeljarpiain: Hey, your wrote that clojure in clojure compiler, right?
10:42jarpiainyeah, still missing some special forms
10:43fliebeljarpiain: 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:45jarpiainno official word but it's there if anyone wants it
10:46fliebeljarpiain: Have you tried persuading rich or someone else form the core team?
10:46dnolenjarpiain: 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:49stuartsierraSpeaking 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:50jarpiaindnolen: it's a monadic translation of clojure.lang.Compiler
10:50jarpiaindepends on c.l.Reflector, should use clojure.reflect instead to get a sane implementation of deftype and reify
10:51dnolenjarpiain: 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:52fliebelsad 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:53TimMcWould the goal be to get a completely self-hosted Clojure?
10:54clgvis there are shortcut to create a regexp from a string on runtime?
10:54manutter,(doc re-pattern)
10:54clojurebot"([s]); Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher."
10:54clgvah thanks :)
10:54manutternp
10:54stuartsierraTimMc: I think the goal would be to abstract away the specifics of the Java implementation, to make porting easier.
10:54clgv$findfn "bla" #"bla"
10:54sexpbot[]
10:55clgvsxpbot couldnt have done it it seems ;)
10:55gfrlog,(re-pattern "bla")
10:55clojurebot#"bla"
10:55jarpiain(= #"bla" #"bla")
10:55gfrlog(= #"bla" (re-pattern "bla"))
10:55jarpiain,(= #"bla" #"bla")
10:55clojurebotfalse
10:56gfrlogwell that's it
10:56gfrlog,({#"well" "haha"} #"well")
10:56clojurebotnil
10:56clgvah kk^^
10:56gfrlogI guess I should stop using regexes as keys in my maps
10:58Fossi-_-
11:00gfrlog(defn unapply [f & args] (f args))
11:02clgvlol
11:14S11001001gfrlog: you mean funcall surely
11:14S11001001oh I can't read never mind
11:15mabesdoes 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:18chousermabes: a protocol function *is* a function, so memoize can be used just as it would be on any function
11:19mabeschouser: sure, but I want to apply the memorization to all the functions not just a record's specific implementation of it
11:19chouserI 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:20chousermabes: (defprotocol P (pf [_])) (def pf2 (memoize pf))
11:20chouserevery call to pf2 will be memoized, regardless of the specific implementation of pf
11:21mabeschouser: 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:24gfrlogmabes: 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:24gfrlogs/meoized/memoized
11:24sexpbot<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:25gfrlogI mean I could imagine protocols being implemented in a way that would allow that, but I doubt they were...
11:26mabesI figured it out
11:27gfrlogyeah?
11:27chouseroh, I suppose you can (def pf (memoize pf)), but I don't think I'd recommend it
11:28devnso if im using 1.3.0-master-SNAPSHOT, what's the "right" way to use contrib?
11:29mabeschouser: heh, that that is what I just did :)
11:29mabes(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:30mabeschouser: what are the potential issues with the above approach?
11:31chouseroh, storing the original off to the side like that is probably a bit better than losing it entirely
11:31chouserthe only remaining problem I can think of is the performance issue I mentioned earlier.
11:33fogus`The reason to use memoization in the first place is to gain some performance no? Maybe it's a wash.
11:33mabesYeah, the fastest approach would probably be to duplicate the memoization call in each of the record's version...
11:33fliebelI think extend takes actual fn objects, so you could write the record empty, and extend the memoized fns onto it.
11:34chouserif the implementations are really slow and the function is call relatively infrequently, I can imagine the memoize could be a big win
11:34mabesyeah, 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:34fogus`(inc fliebel)
11:34sexpbot⟹ 3
11:35mabeschouser: my function in question can take up to several hours :)
11:35chouserheh, right, so the inlining of the call really isn't going to help
11:35fogus`mabes: I'm not sure that call-site caching helps ;-)
11:35chouseryou might consider multimethods for a situation like that.
11:35ilyakHi *
11:36mabesthanks all for the feedback and help
11:36chousermabes: do your impementations call themselves at all?
11:36ilyakWhat'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:36ilyakProblem is, Work's callback method returns void
11:37chouserilyak: Ugh. Shared mutable state.
11:37ilyakSo I need to stash that value in some kind of mutable (or final as in settable-once) container
11:37mabeschouser: they will call the same function on different records internally
11:37ilyakand then return it
11:37ilyakWhat's the best primitive to use?
11:37ilyakref? atom? something else?
11:37ilyakchouser: It would be pure if not for void return type
11:38chousermabes: be careful then that they're calling the memoized version (assuming that's what you want)
11:38mabeschouser: good point, let me verify that it works as I expect...
11:38chouserilyak: right, I'm saying that api is forcing you to use shared mutable state. An atom or a promise might work well enough.
11:40mabesilyak: 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:41ilyakmabes: see hibernate's Work class
11:41ilyakI need to compute some value in its only method and then use it somewhere
11:42ilyakwhich is tricky since it returns void
11:42ilyaks/class/interface
11:42dnolenfogus`: I replied on the ML, were there specific questions you had?
11:42fogus`dnolen: Probably. I will read what you have after lunch and try to articulate myself.
11:43dakronednolen: are you going to be publishing design stuff to a wiki somewhere?
11:43mabesilyak: this class? http://docs.jboss.org/hibernate/core/3.5/api/
11:43mabesilyak: er... frames.. one sec
11:44mabesilyak: this one? http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/jdbc/Work.html
11:45dnolendakrone: 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:45dakronednolen: I shall read the papers first then
11:46mabesdoes reify replace proxy or is proxy still the preferred function for creating on-the-fly java classes/instances?
11:47mabes(I know reify is used for anonymous protocol impls)
11:47chousermabes: reify is better when you can use it, but refuses to extend concrete classes
11:47mabesah, makes sense
11:47chouserit'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:48chouserwhich is a pain since the syntax is different. :-P
11:48KirinDavechouser: I hope moving forward that particular problem is fixed.
11:48chouserbut I have a macro that lets you use reify-style syntax for a proxy, in case that's helpful.
11:48KirinDavechouser: Most everyone I've talked to so far ends up writing elaborate macros to avoid dealing with it.
11:49chouseryeah
11:49KirinDavechouser: (as well as to avoid dealing with the static-dynamic divide)
11:49chouserhttps://gist.github.com/871513
11:50KirinDaveIndeed
11:50KirinDaveNot an unfamiliar pattern to me.
11:56dnolenchouser: 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:57chouserI 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:57chouserjust a simple syntactic problem
11:59chouserproxy's syntax is poor because it captures 'this' and now is out of date because it's dissimilar to reify/defrecord/deftype/extend
12:00gfrlogthere aren't any conventional semantics for vars that begin with dollar-signs are there?
12:01gfrlog(I noticed incanter using one)
12:03mabesgfrlog: not that I know of.. I think incacnter's use is more JS inspired.. (e.g. the do everything operator :) )
12:03gfrlogvery good
12:04mabeschouser: 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:05mabeshmm.. actually, that is not testing what I wanted to test.. hang on
12:10mabesyeah, it still works as expected: https://gist.github.com/970804
12:11KneferilisHello!
12:11Kneferilisany programmers of clojure .NET?
12:19dnolenKneferilis: there a couple, might be easier to ping the mailing list if you have a specific question.
12:20Kneferilisdnolen: I see, thanks.
12:25mprenticei 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:15KneferilisHello!
13:16Kneferilishow do I find information on the clojar libraries?
13:16vinzent_clojars.org? or what do you mean
13:17manutterhave a look at http://www.clojure-toolbox.com/
13:17amalloy(inc manutter)
13:17sexpbot⟹ 1
13:17manutterIt's not strictly a guide to clojars, but it's a good ref
13:17manutterlol, tks sexpbot :)
13:17amalloythere's another site a lot like that one, but i forget what it's called
13:17vinzent_manutter, cool, thanks for the link
13:18manutternp. There's some library info at clojuredocs .org too
13:19Kneferilismanutter: thanks
13:58ilyak,(use clojure.set :as sets)
13:58clojurebotjava.lang.ClassNotFoundException: clojure.set
13:58ilyakwhy?
13:58clojurebothttp://clojure.org/rationale
13:58stuartsierrailyak: you need (use '[clojure.set :as sets])
13:59dnolennice literal support for deftype/record in master
14:02vinzent_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:02TimMcdnolen: Yeah?
14:02dnolenTimMc: yup.
14:03TimMcOK, I'll look it up for myself.
14:03fliebeldnolen: Link? What does it look like? Just #=(foo 1 2 3)?
14:03fliebelAre constructors implemented as well already?
14:03dnolen#user.A[nil, nil] for type, #user.B{:a nil, :b nil} for record.
14:05fliebelHm, same thing of course. I was thinking functions where going to be created for constructors, like (foo: 1 2 3)
14:05TimMcdnolen: So, namespace-qualified names are required?
14:05fogus`lunchdefrecords allow both forms
14:17dnolenTimMc: as far I can tell yes.
14:17dnolenfliebel: I don't see auto-generated ctors.
14:18fogus`ctors?
14:19dnolenfogus: sorry i mean constructor fns.
14:19fliebeldnolen: I guess literals kind of offer the same functionality, right?
14:19fogus`I see. For defrecords 2 are generated map->R and ->R and for types only ->T
14:20dnolenfogus`: whoa, sweet
14:22chouserI guess if we're going to have new names being auto-defined, having them look like syntax is better than not.
14:23fliebelYea, it's kind of confusing if you ask me, having #foo.Bar[1 2 3] and (->Bar 1 2 3)
14:24hiredmanfliebel: one is run by the reader, the other is a function call
14:24hiredmanit's like ^ vs. with-meta
14:25fliebelright
14:25stuartsierraClojure 1.3.0-alpha7 is out the door with these additions.
14:26amalloystuartsierra: i don't know how to navigate jira. is http://dev.clojure.org/jira/browse/CLJ-426 included in that alpha?
14:27alandipertamalloy: yes that's in
14:28fliebelstuartsierra: As of, now?
14:29amalloythanks alandipert
14:29stuartsierraas of, seconds ago
14:30fliebelwee :)
14:32rlbis 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:32rlbI can think of ways to do it, but so far they're not as clean as I'd like.
14:33stuartsierrarlb: Scopes! (which don't exist yet)
14:33stuartsierraWe've spent a lot of time talking about this problem, but never came up with a clean solution either.
14:34stuartsierrarlb: Dynamic binding is the tool for doing things like this.
14:35rlbstuartsierra: assuming you mean (binding ...), then right, but (as you probably assumed) I need per-context counting.
14:36hiredman(binding [*foo* (or *foo* (new-foo))] ...)
14:36rlbhiredman: sure, but what if I have a nested with-foo for some other resource.
14:36stuartsierrayes, or make the thing you bind a stack or a counter
14:36rlbi.e. the *foo* needs to be more like macro scoping.
14:37rlb(that didn't make sense...)
14:37hiredmanrlb: I am very aware that it didn't
14:37rlbanyway -- I probably just need to track the counter in the param...
14:37stuartsierra(binding [*foo* (cons (new-foo) *foo*)] …)
14:37dnolenfogus`: there no new reflection stuff on types/records is there?
14:38rlbhiredman: wrt not making sense, I meant me (in case it wasn't clear).
14:40fogus`dnolen: What did you have in mind?
14:41hiredmanrlb: it was
14:41rlbstuartsierra: 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:42stuartsierrarlb: you can do that with `binding` and a counter.
14:42dnolenfogus`: pattern matching of course, seems like literals should be allow for matching.
14:43dnolenfogus`: stuartsierra: are these literals supported in case as well?
14:43stuartsierraI'm guessing not, since they're not compile-time constants.
14:43Kneferilishi
14:44hiredmanstuartsierra: aren't they? by the time the compile compiles the case statement the read has created the record, no?
14:45hiredmancompiler
14:45hiredmanreader
14:45stuartsierradunno
14:45fogus`Yeah, the result of the literal is a record
14:45fogus`(let [{a :a} #user.R[42]] #{a}) => #{42}
14:46hiredmanthats kind of what 'literal' means, yes? created by the reader
14:46fogus`(let [r #user.R[42]] (case r nil :foo #user.R[42] :yay)) => :yay
14:47hiredmanneato
14:47stuartsierra`case` just needs to be able to compute a hash code at compile time, so it should work.
14:48fogus`(into #user.R{} {:a 42 :b 108}) => #user.R{:a 42, :b 108}
14:48rlbstuartsierra: were you still talking about a stack too?
14:48rlbI was thinking about (with-conn c1 ... (with-conn c2 (foo c1))))
14:48rlbwhere foo also calls (with-conn c1) at some point.
14:48jarpiainhow would (defrecord R [x y z] ... (foo [_] #user.R[1 2 3])) work then? (does it?)
14:49stuartsierrarlb: All you need there is a counter.
14:49rlbI need a counter for c1 and a counter for c2.
14:49hiredmanjarpiain: can't work
14:49fogus`jarpiain: foo would return the same as (R. 1 2 3)
14:50fogus`oh wait... I see
14:50dakronestuartsierra: do you know how long it will be before alpha7 makes it to maven?
14:50fogus`foo is in the body of R
14:50stuartsierradakrone: between 1 and 24 hours
14:50dakroneroger, thanks
14:52fliebelDo vectors have some super fast way of putting 2 together?
14:52chouserfliebel: into, O(m)
14:52rlb(and the with-conn in foo just needs to be able to find the count for c1)
14:53fliebelchouser: Weee :)
14:53fogus`jarpiain: hiredman is right... at that point it doesn't exit yet
14:53dnolenfogus`: ah, I see, case will work w/ records not types.
14:53ilyakWhere can I read about clojure compiler syntax?
14:53ilyakI want to integrate it into ant
14:54ilyakHow do I tell clojure compiler to compile all .clj files it finds in a tree starting with <dir>?
14:54ilyak(as opposed to passing every single namespace)
14:55chouserfliebel: finger trees have an O(log n) concat. *shrug*
14:55fliebelchouser: Yea, they are awesome :)
15:07rlbstuartsierra: perhaps for light use:
15:07rlb(defmacro with-conn [c & forms]
15:07rlb `(if (contains? *connections* c) (do ~@forms) (try ...)))
15:07rlb
15:08rlbAnd of course only within a single thread.
15:23scgilardirlb: 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:24rlb(btw my syntax was all wrong -- just starting to use clojure's defmacro -- mixed up ~ and #, etc.)
15:24rlbscgilardi: thanks
15:28rlbscgilardi: that looks similar to what I was thinking, though I've been using a set rather than a counter.
15:47scgilardirlb, cool, yw
16:08dnolenclojure-mode needs fixin for deftype/record literal syntax...
16:37amalloydnolen: good point. what have you noticed that breaks?
16:42hugodamalloy: did you get a chance to play with the swank-clj debugger?
16:50amalloyhugod: no, haven't done any clojure for a couple days. life getting in the way
16:51hugod:)
16:51dnolenamalloy: vectors and maps need to check that they aren't proceeded by literal record/type prefix
16:52amalloydnolen: in what context? like, for syntax highlighting, sending to swank, or what?
16:53dnolenamalloy: correction, paredit needs to be tweaked it seems.
16:54amalloyreally? 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:55dnolenamalloy: paredit want to put a space, "#user.A [^]", ^ is the cursor.
16:55dnolenspace between A and [
16:56amalloyaha
17:02amalloydnolen: i think i see a simple and not-very-hacky way to do that
17:03dnolenamalloy: cool!
17:03amalloy(save-excursion (backwards-sexp) (looking-at "#")) should tell us whether point is in or after a token starting with #
17:05amalloyi 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:10amalloydnolen: ooc does that cause the reader to break, or just look ugly?
17:16dnolenamalloy: reader breaks, swank-clojure needs to be fixed as well.
17:16dnolen#user.A[0 0]^, C-x C-e is broken
17:17amalloydnolen: i assume it's just sending [0 0] though, because last-sexp isn't slurping it up
17:17dnolenamalloy: yup
17:18amalloydnolen: does [#user.A[0 0]]^ work?
17:19dnolenamalloy: yes
17:20amalloythen swank probably doesn't need fixing, just slime
17:20amalloysadly i know a lot less about slime than paredit
17:30amalloydnolen: 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:31amalloyif 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:02mprenticecan i stop the thread started by clojure.contrib.lazy-xml/parse-trim ? it's staying open after i'm done with the file.
22:25stevenhey guys
22:25stevenwhats a better way of doing (rest (rest form))
22:26stevenassuming form is a list
22:33tomojif you're OK with (next (next form)) instead there's nnext
22:38stevenokay, thanks
22:42tomojthe only difference in the case of a list being that if the list has two elements it will return nil instead of ()
23:57amalloy$findfn [1 2 3 4] [3 4]
23:57sexpbot[clojure.core/nnext]
23:57amalloysteven: ^ can help