#clojure logs

2011-03-09

00:00waxroseYeah
00:00waxroseYeah
00:08waxroseI'm still going to check out this lisp/bf interpreter just for fun.
00:08waxroseI'm still going to check out this lisp/bf interpreter just for fun.
02:05amalloyTimMc: oh hey, you go to the same school as ben englert, apparently
02:05amalloyTimMc: oh hey, you go to the same school as ben englert, apparently
02:06amalloyfriend of mine; he did a summer internship at my previous company
02:06amalloyfriend of mine; he did a summer internship at my previous company
02:36amalloydoes anyone have a dsl/library for state machines? i started writing what turned out to be a pushdown automaton, and i'd like to either use an existing one or put together a generic one of my own for release
02:36amalloydoes anyone have a dsl/library for state machines? i started writing what turned out to be a pushdown automaton, and i'd like to either use an existing one or put together a generic one of my own for release
02:41amalloyit also seems like fnparse "ought" to be usable as a state machine but i can't figure out how to squish the two mental-models together
02:41amalloyit also seems like fnparse "ought" to be usable as a state machine but i can't figure out how to squish the two mental-models together
02:48hiredmanamalloy: I generally use letfn + trampoline
02:48hiredmanamalloy: I generally use letfn + trampoline
02:52amalloyhiredman: cute
02:52amalloyhiredman: cute
02:54hiredmanhttps://github.com/hiredman/chinese-democracy/blob/master/src/chinese/democracy.clj#L28
02:54hiredmanhttps://github.com/hiredman/chinese-democracy/blob/master/src/chinese/democracy.clj#L28
02:57amalloysounds perfect for finite-state; seems like it will involve more low-level fiddling than i'd like for maintaining unbounded state like a stack
02:57amalloysounds perfect for finite-state; seems like it will involve more low-level fiddling than i'd like for maintaining unbounded state like a stack
03:03amalloyi guess it's hard to get much shorter than #(next-state current-stack), #(next-state (conj current-stack new-value)), and #(next-state (pop current-stack))
03:03amalloyi guess it's hard to get much shorter than #(next-state current-stack), #(next-state (conj current-stack new-value)), and #(next-state (pop current-stack))
03:35angermanis there a command to clear the clojure repl in emacs?
03:35angermanis there a command to clear the clojure repl in emacs?
03:39amalloyangerman: clear it how?
03:39amalloyangerman: clear it how?
03:40longfinangerman: if you use slime, m-x slime-clear-buffer
03:40longfinangerman: if you use slime, m-x slime-clear-buffer
03:40longfinsorry m-x slime-repl-clear-buffer
03:40longfinsorry m-x slime-repl-clear-buffer
03:41angermanlongfin: thanks!
03:41angermanlongfin: thanks!
03:41amalloyangerman: C-c M-o does the same thing
03:41amalloyangerman: C-c M-o does the same thing
03:41amalloyas long as what you want is to clear the screen rather than "restart" the repl from a clean state; your use of clear was, aha, unclear to me
03:41amalloyas long as what you want is to clear the screen rather than "restart" the repl from a clean state; your use of clear was, aha, unclear to me
03:42angermanamalloy: well is there a way to restart the repl without restarting the whole process?
03:42angermanamalloy: well is there a way to restart the repl without restarting the whole process?
03:42amalloynot as far as i'm aware
03:42amalloynot as far as i'm aware
03:44longfinm-x slime-list-connections to display connection list,
03:44longfinm-x slime-list-connections to display connection list,
03:45amalloyyeah, i just found that myself, under C-c C-x c
03:45amalloyyeah, i just found that myself, under C-c C-x c
03:45longfinthen m-x slime-quit-connection-at-point..
03:45longfinthen m-x slime-quit-connection-at-point..
03:45amalloylongfin: that won't do anything because the swank server for that connection will still have all the same vars bound
03:45amalloylongfin: that won't do anything because the swank server for that connection will still have all the same vars bound
03:46longfinuhm, you're right.
03:46longfinuhm, you're right.
03:47amalloyi need to get the hang of having more than one connection open; it's really a pain for me to work on more than one thing at a time currently :P
03:47amalloyi need to get the hang of having more than one connection open; it's really a pain for me to work on more than one thing at a time currently :P
04:03raekangerman: it is often possible to repair the "damage"
04:03raekangerman: it is often possible to repair the "damage"
04:04raekfor example by using ns-unmap and remove-ns
04:04raekfor example by using ns-unmap and remove-ns
04:12krumholthello. will reset! block until the atom has changed? and is it possible that the order of evaluation will get changed if i do (reset! ...) @done and "done" is a promise i am waiting on?
04:12krumholthello. will reset! block until the atom has changed? and is it possible that the order of evaluation will get changed if i do (reset! ...) @done and "done" is a promise i am waiting on?
04:13hiredmanatoms are synchronous
04:13hiredmanatoms are synchronous
04:15raekkrumholt: when reset! returns, the change is done
04:15raekkrumholt: when reset! returns, the change is done
04:16raekbut the attempt to reset the atom may have been repeated
04:16raekbut the attempt to reset the atom may have been repeated
04:16krumholtok thanks maybe there is my problem
04:16krumholtok thanks maybe there is my problem
04:17raekhrm
04:17raekhrm
04:17raekmaybe reset! does not "repeat" after all
04:17raekmaybe reset! does not "repeat" after all
04:18raekreset! results in a call to .set on an AtomicReference
04:18raekreset! results in a call to .set on an AtomicReference
04:19raekand there is no loop in the source code
04:19raekand there is no loop in the source code
04:19krumholtok
04:19krumholtok
04:19raekanyway, reset! is a function, so the argument you send it is only evaluated once
04:19raekanyway, reset! is a function, so the argument you send it is only evaluated once
04:20raekswap! simply invokes the function you pass it one or more times (still following the usual order of evaluation)
04:20raekswap! simply invokes the function you pass it one or more times (still following the usual order of evaluation)
04:54angermanhmm. (prn [a b]) ;; => Don't know how to create ISeq from: java.lang.Integer
04:54angermanhmm. (prn [a b]) ;; => Don't know how to create ISeq from: java.lang.Integer
04:54angerman?!
04:54angerman?!
04:55raek,(let [a 1, b 2] (prn [a b]))
04:55raek,(let [a 1, b 2] (prn [a b]))
04:55clojurebot[1 2]
04:55clojurebot[1 2]
04:56angermanreak. right now it makes no sense at all to me :/
04:56angermanreak. right now it makes no sense at all to me :/
04:56raek,(let [[x y] 1] nil)
04:56raek,(let [[x y] 1] nil)
04:56clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
04:56clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
04:56angermanahh. i'm getting a nil...
04:56angermanahh. i'm getting a nil...
04:56raekangerman: are you really sure that the exception originates from that code?
04:56raekangerman: are you really sure that the exception originates from that code?
04:57angermanreak, yes, that's what the stacktrace sais.
04:57angermanreak, yes, that's what the stacktrace sais.
04:57raek,(map inc 1)
04:57raek,(map inc 1)
04:57clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
04:57clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
04:57clgv,(1 [a b])
04:57clgv,(1 [a b])
04:57clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
04:57clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
04:58clgv,(1 [2 4])
04:58clgv,(1 [2 4])
04:58clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
04:58clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
04:58raekthe exception says that you are trying to feed an integer into a function that takes a seq
04:58raekthe exception says that you are trying to feed an integer into a function that takes a seq
04:58clgvoh ok thats different
04:58clgvoh ok thats different
05:01angermanjikes.
05:01angermanjikes.
05:01angermanapply is mean
05:01angermanapply is mean
05:01__name__good morning.
05:01__name__good morning.
05:01angermanhard to track down :/
05:01angermanhard to track down :/
05:02angerman__name__: you ment to enter #python?
05:02angerman__name__: you ment to enter #python?
05:02angerman;D
05:02angerman;D
05:02waxrose:P
05:02waxrose:P
05:02__name__angerman: I do use Python, yes.
05:02__name__angerman: I do use Python, yes.
05:37bartj, (merge-with + ([:c 5] [:b 2] [:c 3]))
05:37bartj, (merge-with + ([:c 5] [:b 2] [:c 3]))
05:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentVector
05:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentVector
05:37bartj, (merge-with + '([:c 5] [:b 2] [:c 3]))
05:37bartj, (merge-with + '([:c 5] [:b 2] [:c 3]))
05:37clojurebot([:c 5] [:b 2] [:c 3])
05:37clojurebot([:c 5] [:b 2] [:c 3])
05:37bartjwhy doesn't it give ([:c 8] [:b 2])
05:37bartjwhy doesn't it give ([:c 8] [:b 2])
05:42__name__, (merge-with + ([:c 5] [:b 2] [:c 3]))
05:42__name__, (merge-with + ([:c 5] [:b 2] [:c 3]))
05:42clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentVector
05:42clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: PersistentVector
05:46Chousukeyou need maps, not vectors. :/
05:46Chousukeyou need maps, not vectors. :/
06:22angermanCatmull Clark and Doo Sabin subdivision with Clojure and jReality: http://dl.dropbox.com/u/281539/jReality-SubD-CC-and-DS-small.mov
06:22angermanCatmull Clark and Doo Sabin subdivision with Clojure and jReality: http://dl.dropbox.com/u/281539/jReality-SubD-CC-and-DS-small.mov
06:47pyris there any standard document for coding style in lisp (or clojure)
06:47pyris there any standard document for coding style in lisp (or clojure)
06:48pyri use 2 space indent and let vim do the work mostly but wouldn't want to derive from an existing standard too much if there is such a thing
06:48pyri use 2 space indent and let vim do the work mostly but wouldn't want to derive from an existing standard too much if there is such a thing
06:50Bronsapyr: try this http://ddm.ace.ed.ac.uk/staff/michael/class/moz/cm/doc/contrib/lispstyle.html
06:50Bronsapyr: try this http://ddm.ace.ed.ac.uk/staff/michael/class/moz/cm/doc/contrib/lispstyle.html
06:50pyrBronsa: thanks
06:50pyrBronsa: thanks
06:54Dranikhi all!
06:54Dranikhi all!
07:04pyrtsawhois pyr
07:04pyrtsawhois pyr
07:04pyrtsaX)
07:04pyrtsaX)
07:13fliebelmorning
07:13fliebelmorning
07:21kilotrying to install counterclockwise, eclipse says "the repository seems to be empty" - am using tutorial listed in the googlecode page of counterclockwise - http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Eclipse_and_Counterclockwise
07:21kilotrying to install counterclockwise, eclipse says "the repository seems to be empty" - am using tutorial listed in the googlecode page of counterclockwise - http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Eclipse_and_Counterclockwise
07:21kilocan anyone help ?
07:21kilocan anyone help ?
07:22octeis there a convienence function for making a java.util.List from a seq?
07:22octeis there a convienence function for making a java.util.List from a seq?
07:23clgvkilo: I installed mine from that location: http://updatesite.counterclockwise.googlecode.com/hg/
07:23clgvkilo: I installed mine from that location: http://updatesite.counterclockwise.googlecode.com/hg/
07:24kiloclgv: am i doing it right - help-software updates-available software - add site - put the url - ?
07:24kiloclgv: am i doing it right - help-software updates-available software - add site - put the url - ?
07:25clgvkilo: yeah. that's what I did
07:25clgvkilo: yeah. that's what I did
07:25kiloi get " No repository found at http://updatesite.counterclockwise.googlecode.com/hg/"
07:25kiloi get " No repository found at http://updatesite.counterclockwise.googlecode.com/hg/"
07:25clgvI have Eclipse 3.6.1 here
07:25clgvI have Eclipse 3.6.1 here
07:26kilowoops
07:26kilowoops
07:26clgvHelp > Install New Software, I used "Add..." to add the url above
07:26clgvHelp > Install New Software, I used "Add..." to add the url above
07:27kiloi'm on 3.4
07:27kiloi'm on 3.4
07:30clgvkilo: I can't tell if that might be a problem...
07:30clgvkilo: I can't tell if that might be a problem...
07:31kilok
07:31kilok
07:32clgvI just did a search for updates and it didnt report any failure
07:32clgvI just did a search for updates and it didnt report any failure
07:36octe,(sort (comparator (fn [x y] (- y x))) '(1 9 5 2 3))
07:36octe,(sort (comparator (fn [x y] (- y x))) '(1 9 5 2 3))
07:36clojurebot(1 9 5 2 3)
07:36clojurebot(1 9 5 2 3)
07:36octeshould'nt that work?
07:36octeshould'nt that work?
07:36octehm
07:36octehm
07:41morphlingocte: comparator makes a comparator from a predicate
07:41morphlingocte: comparator makes a comparator from a predicate
07:42TimMcamalloy_: Thanks for mentioning partially-ordered sets -- I found c.c.graph, which has a function to do something like a topo sort.
07:42TimMcamalloy_: Thanks for mentioning partially-ordered sets -- I found c.c.graph, which has a function to do something like a topo sort.
07:42spewn,(sort (comparator <) '(1 9 5 2 3))
07:42spewn,(sort (comparator <) '(1 9 5 2 3))
07:42clojurebot(1 2 3 5 9)
07:42clojurebot(1 2 3 5 9)
07:43octeah
07:43octeah
07:43spewnWhy is there need to use a Comparator object, rather than just using the predicate directly?
07:43spewnWhy is there need to use a Comparator object, rather than just using the predicate directly?
07:43octeactually, what i want to sort is a seq of java objects which have a date field
07:43octeactually, what i want to sort is a seq of java objects which have a date field
07:44octeand i want it sorted reverse chronological
07:44octeand i want it sorted reverse chronological
07:45clgvthat works well: ##(sort (fn [x y] (- y x)) '(1 9 5 2 3))
07:45clgvthat works well: ##(sort (fn [x y] (- y x)) '(1 9 5 2 3))
07:45sexpbot⟹ (9 5 3 2 1)
07:45sexpbot⟹ (9 5 3 2 1)
07:46octethanks
07:46octethanks
07:49spewn&(doc sort)
07:49spewn&(doc sort)
07:49sexpbot⟹ "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
07:49sexpbot⟹ "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
07:49spewnclgv: So why does that work?
07:49spewnclgv: So why does that work?
07:50TimMc,(sort < '(1 9 5 2 3))
07:50TimMc,(sort < '(1 9 5 2 3))
07:50clojurebot(1 2 3 5 9)
07:50clojurebot(1 2 3 5 9)
07:50clgvspewn: I guess since it probably uses the comparator semantic internally. but to be sure you'd have to look at the source
07:50clgvspewn: I guess since it probably uses the comparator semantic internally. but to be sure you'd have to look at the source
07:51clgv$source sort
07:51clgv$source sort
07:51sexpbotsort is http://is.gd/EUo3np
07:51sexpbotsort is http://is.gd/EUo3np
07:52ChousukeIFn or AFn implements Comparator I think
07:52ChousukeIFn or AFn implements Comparator I think
07:52spewnInteresting... ##(.compare > 5 6)
07:52spewnInteresting... ##(.compare > 5 6)
07:52sexpbot⟹ 1
07:52sexpbot⟹ 1
07:52spewnChousuke: That it does.
07:52spewnChousuke: That it does.
07:56powrtocIs there a problem AOTing records in clojure 1.2, if the namespace holding the record has a - in it??
07:56powrtocIs there a problem AOTing records in clojure 1.2, if the namespace holding the record has a - in it??
07:58powrtocI have a record in a namespace called foo-bar.baz (in directory foo_bar.baz), but when I AOT the record gets compiled to foo.Record rather than foo_bar.baz.Record
07:58powrtocI have a record in a namespace called foo-bar.baz (in directory foo_bar.baz), but when I AOT the record gets compiled to foo.Record rather than foo_bar.baz.Record
07:59clgvpowrtoc: the "-" is ok afaik but the "." could be a problem
07:59clgvpowrtoc: the "-" is ok afaik but the "." could be a problem
08:00powrtoccigv: really? how come?
08:00powrtoccigv: really? how come?
08:00powrtocjava packages are traditionally . seperated, as are clojure namespaces
08:00powrtocjava packages are traditionally . seperated, as are clojure namespaces
08:01clgvoh right. but the directory should be "foor_bar/baz" then, I think
08:01clgvoh right. but the directory should be "foor_bar/baz" then, I think
08:01clgvs/foor/foo/
08:01sexpbot<clgv> oh right. but the directory should be "foo_bar/baz" then, I think
08:01clgvs/foor/foo/
08:01sexpbot<clgv> oh right. but the directory should be "foo_bar/baz" then, I think
08:02powrtocclgv, That's what it is
08:02powrtocclgv, That's what it is
08:02clgvok, then misread you
08:02clgvok, then misread you
08:02powrtocoh sorry... my mistake, I mistyped it
08:02powrtocoh sorry... my mistake, I mistyped it
08:02powrtocthe directories and namespace names are correct AFAIK
08:02powrtocthe directories and namespace names are correct AFAIK
08:03powrtocwhere baz is a file (not a directory)
08:03powrtocwhere baz is a file (not a directory)
08:03powrtocs/baz/baz.clj/
08:03powrtocs/baz/baz.clj/
08:03sexpbot<powrtoc> where baz.clj is a file (not a directory)
08:03sexpbot<powrtoc> where baz.clj is a file (not a directory)
08:04powrtocand baz.clj defines my record Bleh ...
08:04powrtocand baz.clj defines my record Bleh ...
08:05powrtocbut AOTing the namespace results in a class file identified by foo.Bleh rather than foo_bar.baz.Bleh (or foo-bar.baz.Bleh)
08:05powrtocbut AOTing the namespace results in a class file identified by foo.Bleh rather than foo_bar.baz.Bleh (or foo-bar.baz.Bleh)
08:05clgvpowrtoc: I just checked my project, but I don't have records in this kind of namespace names.
08:05clgvpowrtoc: I just checked my project, but I don't have records in this kind of namespace names.
08:05powrtocI'm pretty confused
08:05powrtocI'm pretty confused
08:10clgvdid you try without "-" just to check if it's really the cause?
08:10clgvdid you try without "-" just to check if it's really the cause?
08:10powrtocno just trying that now
08:10powrtocno just trying that now
08:10powrtocit's just a PITA to rename namespaces in my project just now
08:10powrtocit's just a PITA to rename namespaces in my project just now
08:11clgvyou could make a dummy project therefor ;)
08:11clgvyou could make a dummy project therefor ;)
08:11powrtocI am :-) as we speak
08:11powrtocI am :-) as we speak
08:12CozeyHello. So the way to use clojure-contrib 1.3.0 alpha is to use specific clojure contrib modules in :dependencies ?
08:12CozeyHello. So the way to use clojure-contrib 1.3.0 alpha is to use specific clojure contrib modules in :dependencies ?
08:20raekCozey: yes
08:20raekCozey: yes
08:20Cozeyso i should build it from git and then mvn install-file them all?
08:20Cozeyso i should build it from git and then mvn install-file them all?
08:21raekCozey: no, there are SNAPSHOT versions available
08:21raekCozey: no, there are SNAPSHOT versions available
08:21Cozeyuhm? in what repository?
08:21Cozeyuhm? in what repository?
08:21raekwell, you can compile it yourself, but the build server has probably already done it
08:21raekwell, you can compile it yourself, but the build server has probably already done it
08:21raekthe usual clojure one (leiningen uses it by default)
08:21raekthe usual clojure one (leiningen uses it by default)
08:22raekhttp://build.clojure.org/snapshots/org/clojure/contrib/
08:22raekhttp://build.clojure.org/snapshots/org/clojure/contrib/
08:22powrtocok, I can't get records to AOT properly in hyphenated namespaces at all
08:22powrtocok, I can't get records to AOT properly in hyphenated namespaces at all
08:22raekfor instance: [org.clojure.contrib/sql "1.3.0-SNAPSHOT"]
08:22raekfor instance: [org.clojure.contrib/sql "1.3.0-SNAPSHOT"]
08:23Cozeyraek: thanks! that's what i needed
08:23Cozeyraek: thanks! that's what i needed
08:23powrtocjust tried with two projects... one with a record in a namespace records.core, the other in a namespace called hyphenated-records.core ... both records are called Foo... in the hyphenated case I can never find a classfile on disk... I'm using leiningen to generate the projects
08:23powrtocjust tried with two projects... one with a record in a namespace records.core, the other in a namespace called hyphenated-records.core ... both records are called Foo... in the hyphenated case I can never find a classfile on disk... I'm using leiningen to generate the projects
08:24powrtocthe unhyphenated case works as expected
08:24powrtocthe unhyphenated case works as expected
08:25clgvso you should file a bug report on this.
08:25clgvso you should file a bug report on this.
08:36tsdhHi. Can anyone tell me why my macro does only work in its own namespace? http://pastebin.com/p84cmExr
08:36tsdhHi. Can anyone tell me why my macro does only work in its own namespace? http://pastebin.com/p84cmExr
08:38raektsdh: where is *schema-elems* defined?
08:38raektsdh: where is *schema-elems* defined?
08:39tsdhIn the namespace of the macro, which is funql.core.
08:39tsdhIn the namespace of the macro, which is funql.core.
08:40raekwhat happens if you eval funql.core/*schema-elems* in that namespace?
08:40raekwhat happens if you eval funql.core/*schema-elems* in that namespace?
08:40powrtocyup
08:40powrtocyup
08:41raekto me it looks like the macro does what it should, but that the var is somehow missing from funql.core
08:41raekto me it looks like the macro does what it should, but that the var is somehow missing from funql.core
08:42tsdhraek: In both namespaces funql.core and funql.test.core it evals to the empty map. But why do I get the error when evaling the macro in funql.test.core?
08:42tsdhraek: In both namespaces funql.core and funql.test.core it evals to the empty map. But why do I get the error when evaling the macro in funql.test.core?
08:42raek(the paste did not contain its def, so that's why I asked about it)
08:42raek(the paste did not contain its def, so that's why I asked about it)
08:43raekstrange
08:43raekstrange
08:43raekand funql.core is used/required in funql.test.core?
08:43raekand funql.core is used/required in funql.test.core?
08:44tsdhYeah, :use with :reload.
08:44tsdhYeah, :use with :reload.
08:45tsdh(ns funql.test.core (:use [funql.core] :reload) ...)
08:45tsdh(ns funql.test.core (:use [funql.core] :reload) ...)
08:48raekI cant's see anything in the paste that looks wring
08:48raekI cant's see anything in the paste that looks wring
08:48raek*wrong
08:48raek*wrong
08:49raektsdh: could you post the files as they are?
08:49raektsdh: could you post the files as they are?
08:49tsdhraek: Do you have mercurial, then you can clone the project?
08:49tsdhraek: Do you have mercurial, then you can clone the project?
08:51raeksure
08:51raeksure
08:51raekI just wanted to see the ns forms, the place where the macro is used and the place where the "missing" var is defined
08:51raekI just wanted to see the ns forms, the place where the macro is used and the place where the "missing" var is defined
08:52clgvis there already implemented a function that checks whether a list of sets is pairwise disjoint?
08:52clgvis there already implemented a function that checks whether a list of sets is pairwise disjoint?
08:52tsdhraek: https://anonymous:secret@hg.uni-koblenz.de/horn/funql
08:52tsdhraek: https://anonymous:secret@hg.uni-koblenz.de/horn/funql
08:53clgvtsdh: lol. very strong password ;)
08:53clgvtsdh: lol. very strong password ;)
08:54tsdhclgv: Any password for anonymous is strong, isn't it?
08:54tsdhclgv: Any password for anonymous is strong, isn't it?
08:54clgvtsdh: it's only funny to read^^
08:54clgvtsdh: it's only funny to read^^
08:55tsdhraek: Now that is strange! I restarted swank, then compiled the code file, then the test file using C-c C-k in emacs/slime, and it worked. But any additional compile fails with the error.
08:55tsdhraek: Now that is strange! I restarted swank, then compiled the code file, then the test file using C-c C-k in emacs/slime, and it worked. But any additional compile fails with the error.
08:55tsdhraek: And "lein test" also fails with that error.
08:55tsdhraek: And "lein test" also fails with that error.
08:56raektsdh: also, I don't think you should have :reload in there
08:56raektsdh: also, I don't think you should have :reload in there
08:56raekbut I don't see why it should matter for this
08:56raekbut I don't see why it should matter for this
08:57tsdhraek: I used what lein new gave me. I'm clojure newbie. ;-)
08:57tsdhraek: I used what lein new gave me. I'm clojure newbie. ;-)
08:57raekhrm, maybe it was :reload-all that was throwned upon...
08:57raekhrm, maybe it was :reload-all that was throwned upon...
09:00raektsdh: *schema-elems* is not defined anywhere in funql.core
09:00raektsdh: *schema-elems* is not defined anywhere in funql.core
09:00raekso there's your problem
09:00raekso there's your problem
09:00raekbinding only dynamically rebinds the value of an *existing* var
09:00raekbinding only dynamically rebinds the value of an *existing* var
09:01tsdhAhhrg! It's of course *schema-imports*!! :-)
09:01tsdhAhhrg! It's of course *schema-imports*!! :-)
09:01tsdhOMG
09:01tsdhOMG
09:01raekalso note that in your macro, the value of *schema-imports* (in the assoc) is read at macroexpand time
09:01raekalso note that in your macro, the value of *schema-imports* (in the assoc) is read at macroexpand time
09:02raekso *schema-imports* needs to be rebound when the macro is expanded
09:02raekso *schema-imports* needs to be rebound when the macro is expanded
09:03raeklike (binding [*schema-imports* {:foo "bar"}] (defn with-schema-imports [...] ...))
09:03raeklike (binding [*schema-imports* {:foo "bar"}] (defn with-schema-imports [...] ...))
09:03raek...which looks very weird
09:03raek...which looks very weird
09:03tsdhraek: Hm, that's a good point, at least if one wants to use the macro in a nested fashon..
09:03tsdhraek: Hm, that's a good point, at least if one wants to use the macro in a nested fashon..
09:04raekI don't know what the code does, but binding is a runtime construct
09:04raekI don't know what the code does, but binding is a runtime construct
09:04raekin a macro, you might even get away with using a let surrounding the syntax-quoted expression in some times
09:04raekin a macro, you might even get away with using a let surrounding the syntax-quoted expression in some times
09:06tsdhraek: Wouldn't it be possible to let the macro expand to a (assoc *schema-imports* key val key2 val2), which is then evaluated first at runtime.
09:06tsdhraek: Wouldn't it be possible to let the macro expand to a (assoc *schema-imports* key val key2 val2), which is then evaluated first at runtime.
09:06raekyes
09:06raekyes
09:07raekbut since you used the value in the macro, I got the impression that you had the required information at macroexpansion time
09:07raekbut since you used the value in the macro, I got the impression that you had the required information at macroexpansion time
09:07raekand if so, there's no reason to "delay" it to runtime
09:07raekand if so, there's no reason to "delay" it to runtime
09:09raekbut I don't know what the code does and how
09:09raekbut I don't know what the code does and how
09:10raeki.e. I don't know what I am talking about and you should take any advice with a grain/metric tonne of salt
09:10raeki.e. I don't know what I am talking about and you should take any advice with a grain/metric tonne of salt
09:12tsdhraek: No, you are totally correct. When using the macro in nested fashon, the inner would completely erase the outer binding, which is not what I want. Committed and pushed a better variant.
09:12tsdhraek: No, you are totally correct. When using the macro in nested fashon, the inner would completely erase the outer binding, which is not what I want. Committed and pushed a better variant.
09:18anonymouse89is there a way to decompose maps on keyword?
09:18anonymouse89is there a way to decompose maps on keyword?
09:19anonymouse89(or key, rather)
09:19anonymouse89(or key, rather)
09:20raekanonymouse89: what do you mean by decompose? destructuring?
09:20raekanonymouse89: what do you mean by decompose? destructuring?
09:20AWizzArdanonymouse89: {:keys [a b c]}
09:20AWizzArdanonymouse89: {:keys [a b c]}
09:20pjstadig,(map (fn [[k v]] (str "this is the key" k "this is the value v")) {:a :b :c :d})
09:20pjstadig,(map (fn [[k v]] (str "this is the key" k "this is the value v")) {:a :b :c :d})
09:20clojurebot("this is the key:athis is the value v" "this is the key:cthis is the value v")
09:20clojurebot("this is the key:athis is the value v" "this is the key:cthis is the value v")
09:20AWizzArd,(let [{:keys [a b c]} {:a 10, :c 30}] (prn a b c))
09:20AWizzArd,(let [{:keys [a b c]} {:a 10, :c 30}] (prn a b c))
09:20clojurebot10 nil 30
09:20clojurebot10 nil 30
09:21pjstadig,(map (fn [[k v]] (str "this is the key " k " this is the value " v)) {:a :b :c :d})
09:21pjstadig,(map (fn [[k v]] (str "this is the key " k " this is the value " v)) {:a :b :c :d})
09:21clojurebot("this is the key :a this is the value :b" "this is the key :c this is the value :d")
09:21clojurebot("this is the key :a this is the value :b" "this is the key :c this is the value :d")
09:21anonymouse89raek: right, destructuring
09:21anonymouse89raek: right, destructuring
09:21anonymouse89I know about kwargs for fn's. I'm trying to destructure in a let statement
09:21anonymouse89I know about kwargs for fn's. I'm trying to destructure in a let statement
09:22anonymouse89like (let [[:a :b] {:a 1 :b 2}] (println a b))
09:22anonymouse89like (let [[:a :b] {:a 1 :b 2}] (println a b))
09:22anonymouse89(not valid of course)
09:22anonymouse89(not valid of course)
09:23raek,(let [{:keys [a b]} {:a 1, :b 2}] (format "a=%d, b=%d" a b))
09:23raek,(let [{:keys [a b]} {:a 1, :b 2}] (format "a=%d, b=%d" a b))
09:23clojurebot"a=1, b=2"
09:23clojurebot"a=1, b=2"
09:23pjstadigyeah just do what AWizzArd said
09:23pjstadigyeah just do what AWizzArd said
09:23anonymouse89okay, sorry for being silly. Thanks everyone!
09:23anonymouse89okay, sorry for being silly. Thanks everyone!
09:23raek{:keys [a b]} is sugar for {a :a, b :b} (note the order of keywords and symbols)
09:23raek{:keys [a b]} is sugar for {a :a, b :b} (note the order of keywords and symbols)
09:24anonymouse89raek: that makes much more sense now
09:24anonymouse89raek: that makes much more sense now
09:24anonymouse89raek: I thought it was magic
09:24anonymouse89raek: I thought it was magic
09:24raekthere's 'strs' and 'syms' also, when the variables should have the same name as a strings or symbols
09:24raekthere's 'strs' and 'syms' also, when the variables should have the same name as a strings or symbols
09:25raekkeywords are indeed the far most common useage, but clojure can have nay object as a key (and you can destructure with any object too)
09:25raekkeywords are indeed the far most common useage, but clojure can have nay object as a key (and you can destructure with any object too)
09:26raek,(let [{a System/out} {System/out 1}] a)
09:26raek,(let [{a System/out} {System/out 1}] a)
09:26clojurebot1
09:26clojurebot1
09:30semperosjust curious, does anyone here have cake working on Windows 7? I've made multiple attempts over time and have yet to be successful
09:30semperosjust curious, does anyone here have cake working on Windows 7? I've made multiple attempts over time and have yet to be successful
09:36fliebelraek: Any news on thiudinassus?
09:36fliebelraek: Any news on thiudinassus?
09:40raekfliebel: unfortunately not...
09:40raekfliebel: unfortunately not...
09:41fliebelraek: So still phase one, is it?
09:41fliebelraek: So still phase one, is it?
09:44raekyeah :)
09:44raekyeah :)
09:44fliebel(I just noticed your assoc-once might update all keys up to the first one that fails)
09:44fliebel(I just noticed your assoc-once might update all keys up to the first one that fails)
09:46raekbut that intermediate map is never returned?
09:46raekbut that intermediate map is never returned?
09:46fliebeluh, right...
09:46fliebeluh, right...
09:54fliebelraek: Why are you using robert.hooke?
09:54fliebelraek: Why are you using robert.hooke?
10:11powrtochmm.. I'm getting weird NoClassDefFound errors with proxy ... yet reevaluating things work
10:11powrtocany ideas?
10:21clgvfliebel: do you know how to use robert.hook/append?
10:24CozeyI cannot run hiccup with clojure-contrib 1.3.0 - the as-str was moved from clojure.contrib.java-utils.. anybody?
10:27Cozeyoh it was replaced with name
10:33appamattoHowdy. I'm confused about the apparent contradiction between immutability and having access to Java objects (which are mutable)
10:34appamattoAre Java objects viewed with suspicion in Clojure code?
10:34raekmutable ones, I guess so
10:35chouserI would say "handled with care" rather than "viewed with suspicion", but yes.
10:35appamattohmm
10:35appamattoWhat techniques are available to handle them with care?
10:36chouserFortunately they're handled with care in the Java world as well, so there are a fair number of immutable objects available
10:36appamattoI see. So the idiom is to use immutable Java objects as much as possible?
10:36appamatto(as opposed to mutable ones)
10:36angermanhow do I upcase a character?
10:36chouseryes. And when not possible, there are some things you can do.
10:37chouseryou can close over the mutable object so the only access to it is through your own functions
10:37appamattoHmm, do you then do locking on it or some other synchronization?
10:38powrtocDoes anyone know why a call to proxy might generate a NoClassDefFoundError... the classpath looks correct
10:38chouserappamatto: sure
10:38chouserappamatto: or use an agent to serialize access (when pods are ready, they'll help here)
10:42appamattochouser, thanks for explaining
10:47powrtocis it possible just to AOT a record with leiningen rather than the whole namespace?
10:52chouserpowrtoc: doubt it. you could put it in a separate namespace of course.
10:52powrtochmm probably not worth it
10:55mefestoHey everyone. I'm using ring, moustache and lein-ring. I'm able to serve static files while running locally (lein ring server) but I cannot when deployed as a war file. Is there some middleware out there for this?
10:58mefestoOr, is there a way to let requests that do not match any of the routes defined in moustache to fall-through to the web container?
10:59pyrmefesto: can't you do it through the web server ?
11:00pyrmefesto: i usually catch files that exist on disk in nginx and serve them
11:00pyrmefesto: and let the rest of the requests go to the application server
11:00mefestopyr: i could but isn't the purpose of using a war is that you have a single thing to deploy?
11:01pyri guess
11:02mefestowe have a bunch of other java web apps (spring/hibernate). so there is an existing setup that i'd like to continue to use.
11:02TimMcI can't figure out how to use http://richhickey.github.com/clojure-contrib/graph-api.html -- how do I create a graph object?
11:03pyrmefesto: makes sense, can't help you with that though
11:09krumholt_is there a swank-clojure version that works with clojure 1.3 ?
11:11fogus`TimMc: Check this out: https://github.com/richhickey/clojure-contrib/blob/ec6a7579d6b1c0bfa42e3666cfad196cffc966fe/src/main/clojure/clojure/contrib/datalog/softstrat.clj#L30
11:13fliebelclgv: Not yet, but it isn't to complicated…
11:13clgvfliebel: I handled it with a normal add-hook now ;)
11:15TimMcfogus`: THanks, I'll take a look.
11:22krumholt_when i try to use swank with clojure 1.3.0-master-SNAPSHOT and i do (require 'swank.swank) i get CompilerException java.lang.ClassNotFoundException: swank/clj_contrib/pprint$fn__643$pretty_pr_code_STAR___644, compiling:(swank/clj_contrib/pprint.clj:34). any ideas?
11:23AWizzArdkrumholt_: did you try the latest version from http://clojars.org/repo/swank-clojure/swank-clojure/1.3.0-SNAPSHOT/ ?
11:24krumholt_AWizzArd, i pulled the latest version from github and built that with lein multi jar
11:27krumholt_AWizzArd, I just tried and i get the same error with the jar from clojars
11:33AWizzArdkrumholt_: then maybe your Clojure version is very fresh?
11:34AWizzArdMine is just a few days old and works.
11:34AWizzArdkrumholt_: Maybe your Contrib version is too old.
11:35krumholt_i have the new clojure contrib 1.3 and haven't really figured out what parts i need for swank. i think there might be the problem
11:40zippy314,(new String)
11:40clojurebot""
11:41zippy314,(let [q String] (new q))
11:41clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: q
11:41zippy314why?
11:41clojurebotwhy not?
11:43fliebeldnolen: I noticed you implemented the zebra problem in Logos, are there any examples of, for example, sudoku, 8 queens, family stuff, etc… ? I might want to try a few of these. Especially sudoku.
11:45dnolenfliebel: someone did sudoku w/ Jim Duey's version. It would be useful to write regular Clojure versions and logos.minikanren versions of those puzzles and compare expressivity and performance.
11:45zippy314So my question given the above is how to create a factory where the object to be created by new is variable? What's the idiomatic clojure way of doing that?
11:46fliebeldnolen: I will see what i can do. I'm not sure yet if I want to see the other version, or figure it out myself.
11:46AWizzArdzippy314: you should reach around functions that create new objects, not classes
11:47AWizzArdzippy314: if you just have a class c and want to create an instance of it then you will have to use reflection to find a constructor which you would like to call.
11:47zippy314AWizzArd: I'm not sure what you mean "reach around"
11:47AWizzArd,(let [c #(String.)] (c))
11:47clojurebot""
11:48dnolenfliebel: if you figure them out yourself, I'd be happy to add them to logos as examples for other people to refer to.
11:48AWizzArdzippy314: Well, I suppose you want to pass a class in, into some function, because your example seems to illustrate something. In a concrete program we would just write "" vs any of the other constructs, such as (let [c #(String.)] (c))
11:51zippy314AWizzArd: what I am working on is a factory function to which I want to pass a class name, and have it instantiate that class and a do stuff with it.
11:52AWizzArdzippy314: what arguments would you pass in to the constructor?
11:52zippy314AWizzArd: in particular the factory function adds stuff into the initialization parameters of the class, so it doesn't make sense to pass in a new instance. The whole point is that it's a "factory"!
11:53AWizzArdzippy314: well, a factory usually produces things of a specific concept. An apple tree produces apples. Your factory will produce what? All kinds of objects?
11:53zippy314AWizzArd: well, the idea is that its a factory for any number of polymorphic classes that all accept the same initialization params
11:54AWizzArdzippy314: if those classes are known at compile time a macro can help you to generate the factories. Otherwise you will have to do reflection.
11:55zippy314AWizzArd: In that example, my factory produces Trees, but it takes as a parameter Apple, Cherry, Oak, for the specific tree type, and passes in as a parameter, generic parameters liek "organic" "heirloom", etc.
11:56zippy314AWizzArd: hmm I see, I can use a macro.
11:57AWizzArdYes, a macro which can generate #(YourClass. ^YourHint1 arg1, ^YourHint2 arg2) and even name them.
11:58AWizzArdA macro which runs through a loop and generates a bunch of defns for example which then instantiate your objects.
12:05jkkramerTimMc: there's also https://github.com/jkk/loom if you weren't aware of it
12:07zippy314AWizzArd: this seems to work: ,(defmacro znew [klass] `(new ~klass "fish")
12:07angermanjkkramer: interesting.
12:07zippy314,(znew String)
12:07clojurebotjava.lang.Exception: Unable to resolve symbol: znew in this context
12:07TimMcjkkramer: Thanks!
12:08AWizzArdzippy314: Yes, this is the basic step and perhaps already perfectly fine for your purposes.
12:08angermanhmm… maybe I could have based my mesh system on that graph lib. ahh well.
12:09AWizzArdzippy314: aternatively the znew macro can accept a name too and generate a `(defn ~yourname [arg#] (new ~class arg#)) or something like that, and automatically typehint arg#, so that no reflection is needed.
12:10dnolenfliebel: Jim Duey's version solves Zebra in abou 550ms, logos.minikanren in about 5ms. In some basic experiments it seems like many problems that can be solved with Clojure list comprehensions or map/filter/reduce are only about 8-10X slower. I'm interested in closing that gap.
12:10zippy314AWizzArd: I have to read about typehints, I haven't done that yet. Thanks!
12:11AWizzArdzippy314: if you won't generate too many instances it is not required here. But if your znew sits in a tight loop that creates 80k objects, then you want to typehint it.
12:11fliebeldnolen: I am about to start the Sudoku in Logos. I haven't even started to consider how to do it in plain Clojure.
12:11zippy314AWizzArd: ok, got it.
12:12fliebeldnolen: So Logos is certainly more optimized for programmers. Now we only need to optimize for computers as well :)
12:12dnolenfliebel: good luck. fingers crossed you don't run into any issues w/ conde. I'm still plugging away at that, but I really need a whole free day to sort it out, so perhaps sometime this coming weekend.
12:13fliebeldnolen: I'm feeling the same about it. The difference is that you understand what goes wrong, and I don't :(
12:14dnolenfliebel: wouldn't go that far. I'm realizing there are quite a few subtleties that I don't really understand ... yet.
12:17zippy314Macro question: this code works:
12:17fliebeldnolen: Has any-o f the syntax sugar landed yet?
12:17zippy314(defmacro name-hash-factory
12:17zippy314 "create a ref to a hash of named classes"
12:17zippy314 [klass names]
12:17zippy314 `(zipmap ~names (repeatedly (count ~names) #(new ~klass))))
12:17zippy314(oops)
12:17fliebelzippy314: ah! you crossed the three-line paste alarm!
12:17dnolenfliebel: do you mean did I add any-o ?
12:17technomancyis it too github-centric to assume people are going to want a README.md file in new projects?
12:18zippy314(blush)
12:18fliebeldnolen: No, the I meant "any of", like destructuring.
12:18zippy314Here it is without the comment line:
12:18zippy314(defmacro name-hash-factory
12:18zippy314 [klass names]
12:18zippy314 `(zipmap ~names (repeatedly (count ~names) #(new ~klass))))
12:18zippy314That was only three lines!
12:18TimMczippy314: Use gists on github, preferably.
12:18TimMcOr don't use linebreaks.
12:18fliebeltechnomancy: The md part maybe, but readme is fine. I've seen github people use textile and plaintext as well.
12:19dnolenfliebel: no that's gotta wait for this conde stuff to get sorted out. Then I'll tackle the pattern matching stuff.
12:19technomancyfliebel: I'm just wondering since the first thing I do in every project I create is mv README README.md, and the skeletal README is in markdown anyway.
12:19zippy314ok. In any case that code works where the second parameter is a vector of names. If I want to collect all the remaining parameters as a vector using: &, it fails.
12:19zippy314I.e this doesn't work: (defmacro name-hash-factory [klass & names] `(zipmap ~names (repeatedly (count ~names) #(new ~klass))))
12:20zippy314why?
12:20clojurebotwhy not?
12:20fliebeldnolen: Okay, I was thinking it would make it really concise to express a sudoku grid.
12:20dnolenfliebel: yeah it would, you might want to wait until next week :)
12:20AWizzArdzippy314: you could try '~names
12:21AWizzArd(zipmap (10 20 30) [:a :b :c]) <== 10 is not a function
12:21fliebeldnolen: Or do both, to compare the speed and lines of code.
12:21fliebelzippy314: repeatedly takes a function.
12:22AWizzArdfliebel: he passed in a function
12:22zippy314AWizzArd: what does the ' do in front of the ~ ?
12:22fliebelAWizzArd: Oh, I'm misreading again I think :(
12:23AWizzArdzippy314: it quotes it, alternatively you can write (quote ~names)
12:24AWizzArdzippy314: when you call (name-hash-factory String "a" "b" "c") then names will be ("a" "b" "c"). And as zipmap is a function the evaluation rule will have Clojure trying to call the function "a" with the args "b" and "c"
12:24zippy314AWizzArd: But isn't that just (quote (unquote names)) ? Why can't you just have names?
12:24AWizzArdzippy314: call (macroexpand-1 '(name-hash-factory String "a" "b" "c"))
12:25zippy314AWizzArd: I forgot macroexpand. That helps Thanks!
12:25AWizzArd(count ("a" "b" "c")) ==> Exception
12:25AWizzArd(count '("a" "b" "c")) ==> 3
12:25fliebeldnolen: Can Logos express negation? As in 'x is not y'
12:26dnolenfliebel: someone did a Prolog in Ruby a few years ago, and at that time solving Zebra took 25000 milliseconds. logos.minikanren aims to be more usable than that.
12:26fliebeldnolen: Okay, I admit I have been readin abotu Prolog a bit :$
12:27dnolenfliebel: no, though I'll probably add disequality constraints. There are some papers on XSB that I should look into to get some ideas about how to do negation properly in Prolog.
12:28dnolenor a Prolog like lang rather.
12:29fliebeldnolen: With disequality I could revive the decimal arithmetic.
12:29dnolenfliebel: ah interesting. it's really just a constraint that says something can never unify w/ something else.
12:32fliebeldnolen: adder-o uses 1>o to really check if something is 1> by checking the first bit, but the first bit would equal 0-9 for decimal, so I need a way to say 'not 1 and not 0', or I'd end up saying 'not 2, not 3 , not 4 etc…'
12:34dnolenfliebel: yeah it would be something like, (=/= x 1) (=/= x 0)
12:36dnolenfliebel: I encourage you to dig into William Byrd's thesis at this point. It explains the whole machinery for miniKanren in 30 pages or so and it's good reading (more straightforward than TRS).
12:37fliebeldnolen: Does logos have underscore as an unbound value, or do I use (lvar) for that?
12:37fliebeldnolen: Interesting...
12:37krumholt_did something about def change in 1.3 ?
12:38dnolenfliebel: doesn't have _ as unbound, but easy to achieve with clojure.contrib.macro-utils/symbol-macrolet
12:39dnolenfliebel: zebra.clj in the logos project shows this.
12:39fliebelah, I remember seeing that I think.
12:44krumholt,(clojure-version)
12:44clojurebot"1.2.0"
12:44fliebel&(clojure-version)
12:44sexpbot⟹ "1.2.0"
12:45krumholtcan someone confirm that in clojure 1.3.0 the following will not create a macro (try (defmacro foo [a] `~a) 1)\
12:47dnolenkrumholt: works fine for me. 1.3.0-alpha5
12:47krumholtdnolen, did you try (foo 1)
12:47dnolenkrumholt: yup and macroexpand
12:48dnolenkrumholt: and (meta #'foo)
12:48dnolenit all works.
12:48krumholtdnolen, i doesn't work for me
12:49dnolenkrumholt: are you using a plain repl?
12:49krumholtyes
12:50dnolenkrumholt: and alpha5 ?
12:50krumholti am not sure. i just built from github
12:51dnolenkrumholt: that's probably it.
12:55krumholtdnolen, i'll try it with alpha5
12:56krumholtdnolen, just have to built it first
12:58krumholtdnolen, thanks works fine in alpha5
13:00amalloyzippy314: for what it's worth, you don't have to name locals "klass" or "clazz" like you would in java. you can just call them class if you like
13:00zippy314amalloy: Thanks! I'm in the habit of that from ruby...
13:04amalloyclojure lets you shadow anything, even special forms (but don't shadow those; there are weird side effects)
13:04amalloybut class is just a regular function, not a keyword, so the issue doesn't arise
13:04TimMcNot to be confused with actual side effects.
13:16waxroseHello every body.
13:18amalloyTimMc: i am always confused with actual side effects. they're just so confusing
13:20krumholtis there a place to read up on changes from 1.2 to 1.3? i seem to be missing the doc function :)
13:21amalloyocte: (fn [x y] (- y x)) is just (comp - -)
13:41ejacksonok fliebel, I'll fess up.... I wrote some blog posts on this some time back. Check out boss-level.com. You will find such a set of properties for sudoku there :)
13:43fliebelejackson: hmmm, I'm not sure I want to see the complete solution just yet...
13:44ejacksoni wouldn't call my obscurantist ramblings a 'solution' :P
13:46fliebelejackson: Do you know how sets work with logos?
13:47ejacksonnope - i did this pre logos, so using Jim Duey's miniKanren
13:47fliebelejackson: The long way to figure out if a set is valid would be using member-o, but I think it would be quicker to use sets.
13:48ejacksoni used member-o (or mem-o can't recall)
13:49dnolenfliebel: ejackson: one issue is that Prolog doesn't really have data structures beyond lists, they work well with relational programs.
13:50dnolenI don't see how you could use sets relationally (maybe there's a way).
13:50fliebeldnolen: (== [1 2 3 4] #{1 2 3 4})
13:50__name__(&doc ==)
13:50__name__uhm
13:50__name__&(doc ==)
13:50sexpbot⟹ "([x] [x y] [x y & more]); Returns non-nil if nums all have the same value, otherwise false"
13:51dnolenthus William Byrd talks about Purely Relational Data Structures, are there data structure optimized for relational use.
13:51fliebel__name__: This is another ==
13:51fliebeldnolen: I thought you implemented unification with sets?
13:52dnolenfliebel: member-o - if you think about the computational cost, it's not good, you have to potentially traverse the whole list to determine membership. You don't have to do that with proper sets.
13:52dnolenfliebel: I did, but how can you define member-o in terms of sets? (I'm not saying you can't, but I haven't seen how)
13:53fliebeldnolen: I don't need to, I just want to know if a list/vector is equal to #{1 2 3 4 5 6 7 8 9}
13:54fliebelbut (== [1 2 3 4] irc://irc.freenode.net:6667/#%7B1 2 3 4}) does not work.
13:54fliebelThe reason I mentioned member-o, is because it seems to be the only way to tell.
13:54fliebel(i can think of)
13:55dnolenfliebel: you can't unify lists/vectors w/ sets. you can unify sets w/ logic vars in it with other sets.
13:56dnolenand I'm not totally convinced I should even allow that - it's really slow.
13:57fliebeldnolen: Okay, so append-o is the way to go for validating a row of sudoku?
13:57dnolenfliebel: I'm saying I don't really know :) I'm just telling you what little I do know :)
13:59fliebeldnolen: Okay, I'll think some more, I don't like that using append-o would be quadratic time… I think
14:00dnolenfliebel: I think it makes sense to look at a Prolog solution, they've thought about these issues a lot more than I have.
14:01fliebelI see… truth is that prolog has fd_all_different
14:02fliebeland prolog has inequality, which allows you to just say that everything is inequivalent.
14:03dnolenfliebel: ah, fd I think there stands for finite domain. constraint logic programming again.
14:03dnolenfliebel: ejackson: could probably accomplish with disequality constraints.
14:03dnolentoo much to do.
14:04ejacksonyou and me boh
14:13joelrgood day! assuming you did not define a java class, how do you refer to the .class of what clojure will generate?
14:14joelri'm trying to replicate this bit of java:
14:14joelrpublic class ReutersIndexerFinished {
14:14joelr private transient static Log log = LogFactory.getLog(ReutersIndexer.class);
14:14joelrReutersIndexerFinished.class bit
14:18amalloyjoelr: just use clojure.contrib.logging. it automatically constructs and uses a logger for each namespace
14:18joelramalloy: thanks!
14:19joelramalloy: any examples of using that?
14:19amalloythe ".class of what clojure will generate" suggests some misunderstandings, too. clojure generates a class file for each *function*, not each namespace
14:19joelr<- newbie :-(
14:19chousers/not/and also for/
14:19amalloychouser: really?
14:20fogus`Track the progress of 1.3/2.0 http://dev.clojure.org/jira/secure/Dashboard.jspa?selectPageId=10014
14:20chouseramalloy: an *__init class
14:21amalloyjoelr: https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/log.clj is an example i happen to have on hand, but perhaps not a canonical one. it not only logs, but also provides functions for adjusting log levels for other namespaces
14:21joelramalloy: thanks
14:22amalloythe get-logger function it's using is at https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/utilities.clj#L83
14:22amalloychouser: fair enough
14:24fliebeldnolen: What does rember-o do? I have the faint feeling I need it.
14:26dnolenfliebel: returns different answers for a list with a particular item removed.
14:27fliebeldnolen: (rember-o 2 [1 2 3 4] out) (== out [1 3 4])?
14:31dnolenfliebel: answer is actually ((1 3 4) (1 2 3 4), TRS explains why.
14:32fliebelI don't rember reading that… Or wait, maybe I do...
14:41fliebeldnolen: They cover a few pages for ungrounded values, is it in there? Screening the page, I don't see why it would return (1 2 3 4) as well for a fully grounded list.
14:42dnolenfliebel: it's definitely in there - they need to explain why it keeps going.
14:43fliebelokay, reading closely now.
14:46mattmitchellanyone using netbeans + enclojure with a leiningen project?
14:53brehautmorning everyone
14:56amalloy'lo brehaut
14:56waxrosecabalbrehaut, morning/afternoon :D
14:56brehautwaxrosecabal: its always morning in UGT
14:56amalloyit's probably also always morning in NZ. you guys are weird
14:57waxrosecabalIt's 2pm here. :)
14:57amalloy$google irc ugt universal greeting time
14:57sexpbotFirst out of 19 results is: UGT
14:57brehautamalloy: its always the future
14:57sexpbothttp://www.total-knowledge.com/~ilya/mips/ugt.html
14:57amalloywaxrosecabal: ^
14:57brehautUGT?
14:57clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
14:57brehautthats the easy way :P
14:57waxrosecabalbrehaut, XD
14:58joelrhow do you translate file.getName().endsWith(".txt") to clojure? is it (.. file getName (.endsWith "txt")) ?
14:58waxrosecabalamalloy, It's always night time in my room. >.<
14:59amalloyjoelr: close: you're mixing .. and ->
14:59joelramalloy: oh...
14:59amalloyyou could write (.. file getName (endsWith "txt"))
14:59waxrosecabalI should take my laptop outside so I can get a taste of the outside world.
14:59joelramalloy: should i use -> instead?
14:59amalloyi prefer (-> file .getName (.endsWith "txt")) personally
14:59amalloybecause, among other things, it lets you add operations that aren't interop calls
15:00joelramalloy: where can i read up on the difference?
15:00joelramalloy: thanks
15:00amalloy&(macroexpand-all '(-> file .getName (.endsWith "txt")))
15:00sexpbot⟹ (. (. file getName) endsWith "txt")
15:00amalloy&(macroexpand-all '(.. file getName (endsWith "txt")))
15:00sexpbot⟹ (. (. file getName) (endsWith "txt"))
15:00amalloyer
15:00amalloyi'm pretty sure that first macroexpansion isn't right
15:01joelr:D
15:01amalloyoh, i guess it's fine. i don't really know how the . special form works anyway :P
15:01joelrok
15:01fliebeldnolen: They don't explain it very direct, but I think I can see how it just continues and concludes there is nothing else to replace, and returns the full list.
15:05dnolenfliebel: yeah, some of the finer points are implicit, makes the book good for multiple reads I suppose.
15:06fliebel-,- I've got other books waiting ;)
15:12fliebelouch, there got to be a better way than exist'ing 81 variables to get the cols, rows, and blocks
15:13amalloyfliebel: macros!
15:13amalloy(don't know how they're relevant here but they solve everything)
15:14fliebelamalloy: You're right, do the list magic in clojure space, and blit it onto the unifications.
15:14fliebelBut defining all the list magic by cons and recursion is more interesting.
15:14dnolenfliebel: whatever you end up with, try to make it shorter than these, http://www.haskell.org/haskellwiki/Sudoku ;)
15:16fliebeldnolen: It's at least shorter than some of them. Although I'm not sure if that first block is just a snippet or a full solver.
15:17fliebelOh, if it says import sudoku, I guess it's not.
15:18fliebeldnolen: Do you know if there is a place to find more miniKanren sequence stuff than is currently in logos/logic?
15:19fliebelStuff like cycle, take-nth and partition
15:21dnolenfliebel: not really, and I don't know enough of about Prolog to know how to define those or if they're even useful.
15:22dnolenfliebel: hopefully you're realizing that I'm only like 1/4 step ahead of you on most of this stuff.
15:23fliebelehm, no, I'm not. You're my miniKanren guru :P
15:24fliebeldnolen: I think I can implement take and drop by means of rest-o, and go from there to implement take-nth, and maybe others.
15:25fliebelBut implementing clojure/core is going to make my sudoku quite long ;)
15:38fliebelI can't do this stuff around this hour :(
15:41mabeshrm.. *command-line-args* doesn't appear to handle arguments in quotes as a single arg like most langs do.. e.g. foo "bar stuff" => ["foo" "bar" "stuff"]
15:41fogus`fliebel: Fun fun! https://gist.github.com/862962
15:42fliebelfogus`: Easy, easy, I just saw my first lines of prolog today.
15:46fliebelfogus`: Oh, I actually understand it! :) I'm jealous at the ease at which they do I −1 :(
15:46dnolenfliebel: that's not relational tho. You can accomplish the same thing in miniKanren with project.
15:47fliebeldnolen: project?
15:48dnolenfliebel: it gets the value of logic var so you have a real value in a scope.
15:49fliebeldnolen: where do I get it?
15:49dnolenfliebel: it's in logos.nonrel
15:49fliebelwhat is nonrel abaout?
15:49dnolennon-relational operators
15:50fliebelneat
15:50choffsteinHey all. Does anybody here use enlive and can help me figuring out how to insert an image generated dynamically into my site?
15:51choffsteinI can't figure out how to use my templates to insert an image
15:53dnolenfliebel: actually you don't even need project I think, one day soon you'll be able to do this, https://gist.github.com/862975
15:53clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: 503>
15:54fliebeldnolen: With that scheme pairs? yuk! but otherwise, great!
15:54dnolenfliebel: heh not scheme pairs, that just syntax sugar for unifying to LConsSeq
16:23joelrassuming i have a line-seq (from a file), is there a quick one-liner to join the lines in the file using space as a separator?
16:26joelrgot it! (require '[clojure.string :as str])
16:26joelrand str/join
16:26choffsteinIf I have a Java object with a method that expects an input it will write to, but can I use it from clojure? e.g. I want to call ByteArrayInputStream's read method
16:26clojurebotant clean and rebuild contrib
16:27mattmitchellwhat's the BEST clojure editor? I'm lost.
16:29amalloyemacs
16:32raekchoffstein: one way could be to send it an http://download.oracle.com/javase/7/docs/api/java/io/PipedOutputStream.html
16:32choffsteinThanks raek
16:32raekhow do you want to access the data?
16:33raekanother approach could be to proxy InputStream and make it conj the bytes onto a vector wrapped in an atom
16:36raeknice, my ListModel proxy that watches a vector wrapped in an atom works!
16:53zakwilsonclojure.xml/parse is throwing SAXParseException on a file containing "&#x0D" because it evidently doesn't like that. A bit of googling suggests that this character may not be allowed in XML. Regardless, it's in a file I want to parse. What, other than a search and replace can I do to parse the file?
16:56waxrosecabalamalloy, Are you using Emacs 24?
16:56amalloy23
16:57amalloyzakwilson: &#x0D; maybe?
16:57zakwilsonamalloy: I left the semicolon out of what I typed. It's present in the file.
16:58waxrosecabalamalloy, Are you using anything else besides slime for clojure?
16:59amalloywaxrosecabal: not really. slime/swank, clojure-mode, and paredit-mode
17:00mattmitchellamalloy: thanks. good to know.
17:09TimMcwaxrosecabal: pushed
17:09AshWAX
17:10waxrosecabalTimMc, Cool.... I'm about to push an automated script I just made to build Emacs 24 (rather the trunk)... if you are interested
17:10TimMcNah, I'll stick with 23.
17:10TimMcI'm too new at Emacs to go fiddling with it.
17:11waxrosecabalVim user?
17:11TimMcnano :-P
17:11waxrosecabalnice :D
17:11TimMcActually, gedit for everyday editing.
17:11waxrosecabalDidn't consider Vim plugins for Clojure?
17:11waxrosecabalI hear they are pretty decent.
17:12fliebelIf I have a non-executable list inside a macro, what is the right way to make it a real list, instead of a function call?
17:12TimMcwaxrosecabal: I was unfamiliar with both, so I chose the one with more parens.
17:12Chousukefliebel: what do you mean?
17:12spewnfliebel: Quote it?
17:12TimMcfliebel: (list ...)
17:12Chousukefliebel: if you want code from a macro to generate a list, then either generate (quote yourlisthere) or what TimMc said
17:12waxrosecaballol
17:13fliebelChousuke: (defmacro blah [] `(some stuff ~(range 10))) < crude example
17:13Chousukefliebel: some stuff = list
17:14Chousukewith ~@ instead of ~ in range
17:14fliebelChousuke: Problem is that range tells me that it can;t use an integer as a function.
17:14Chousukefliebel: yeah because you'll be generting code that looks like (some stuff (1 2 3 4)) ...
17:14Chousukeyou need the splicing unquote
17:15Chousukeor you can use quote if you have only literals
17:15fliebelah, and then splice it into a list? (list ~@(range 10))
17:15Chousukeyeah
17:16Chousukethen the generated code would be (list 1 2 3 ...) which evaluates to what you want
17:18fliebeldnolen: Guess what, StackOverflowError
17:18waxrosecabalTimMc, Well if you ever become adventurous this is think link to it. It builds Emacs trunk onto an external drive but can be modified of course. https://github.com/waxrosecabal/install_scripts/blob/master/build_emacs.sh
17:18amalloyTimMc: i think my client barfed on me; i tried to say "TimMc: i wrote a blog post about why gedit is a sin and you should use emacs or vim, if you're looking to be made fun of"
17:19TimMcwaxrosecabal: I'm upgrade-shy.
17:19waxrosecabalYou must be an OpenBSD user.
17:19waxrosecaballol
17:19TimMcamalloy: THen you'll love this: I used to use Textpad 4 under Wine once I switched to Linux.
17:19amalloynice
17:20amalloyi used textpad when i was learning java
17:20TimMcIt's actually a damn good editor.
17:20amalloyi was like "omg this is so much better than notepad"
17:20amalloyand it was
17:20TimMcIt's true!
17:20TimMcAnd yet very bare-bones -- it didn't try to be an IDE.
17:20amalloytextpad is roughly like gedit
17:20amalloynotepad is like...some kind of braindead version of either
17:21waxrosecabalWhy not just use mousepad or even leafpad?
17:21TimMcRegex, LRU tabs, macros, external commands, basic syntax highlighting -- what more did I need? :-)
17:21TimMcamalloy: And yet notepad has some of the best Unicode support you'll see anywhere.
17:21TimMc*MRU tabs
17:22__name__TimMc: What makes its Unicode support better?
17:23TimMcOh, I've just heard it is one of the most conforming applications to the Unicode standards.
17:23dnolenfliebel: for your sudoku solver?
17:23TimMcThis was when I worked at Basis Technology, which does i18n and low-level linguistics processing.
17:24waxrosecabalMaybe since I've been a GNU/Linux user for 10+ years, I never did like notepad.
17:24fliebeldnolen: yea
17:24TimMcwaxrosecabal: Notepad is shitty. It's the most basic thing you can have and still call an editor. That's all it was intended to be, though.
17:24TimMcI don't think anyone *likes* it.
17:25__name__Masochists?
17:25amalloyraymond chen has an article somewhere about how notepad always puts the BOM in for UTF-8 documents even if you only use single-byte characters
17:25waxrosecabalTimMc, I find that every time I used notepad then transfered a file over to my Linux.... the file would be infested with "M^"
17:25dnolenfliebel: yeah, honestly I'd relax on logos until I'm 100% sure that I have a correctly functioning base. Or you could starting reading Byrd's paper and help me out ;)
17:25amalloywaxrosecabal: that's not really anything to do with notepad
17:26amalloywindows uses \r\n as line terminators; unix uses \n
17:26waxrosecabalamalloy, Hmm
17:26amalloyyou can configure decent editors (eg textpad) to use either
17:26waxrosecabalI don't really know much about Windows so it would always piss me off.
17:26fliebeldnolen: Hum, both seem a good idea :) I'll think about it.
17:26amalloy*laugh*
17:26waxrosecaballol
17:26TimMcamalloy: Oh yeah, the BOM was annoying.
17:27TimMcMy code got BOMbed more than once.
17:27__name__Storing metainfo inline is evil :(
17:27__name__We just need file meta info … profit!
17:33duncanmi'm using SLIME, and i have a few agents in the REPL
17:33joelrwhat is the 1.2 replacement for duck-streams' reader?
17:33duncanmwhat happens if one of the agents calls 'println'?
17:33duncanmwhere does it go?
17:34duncanmi made call Toolkit.getDefaultToolkit.beep, so i know the function is running, but i can't see any output
17:34joelrfound it
17:35duncanmahhh
17:35duncanmhttp://stackoverflow.com/questions/5132225/how-to-capture-stdout-log-output-of-an-agent-in-slime
17:37raeki usually eval (alter-var-root #'*out* (constantly *out*)) in the emacs slime repl
17:37duncanmraek: have you tried elein?
17:39dnolenfliebel: I could use the help. Ultimately I want to see if a Clojure type checker can be built.
17:41raekduncanm: haven't tried it. is it similar to durendal?
17:41fliebeldnolen: It'd be fun, but also demanding and time consuming :) A type checker?
17:42dnolenfliebel: logic programming makes such things less demanding and time consuming.
17:43duncanmraek: haven't heard from durendal either
17:44dnolenfliebel: Qi has a pretty interesting take on types based on sequent calculus. Would be fun to give a shot that.
17:45fliebeldnolen: I don't know Qi, but I believe you. *googles sequent calculus)
17:45fliebeloh, to late to understand that type of stuff :(
17:48fliebeldnolen: Yup, I think I ran into the same issue again… https://gist.github.com/863180 a full board runs fine.
17:49dnolenfliebel: noted.
17:53ossarehanyone in SF going to the clojure meetup tomorrow at backtype?
18:05amalloyossareh: you can see who's attending from the meetup page
18:05amalloyi don't see george jahad on that list, but he told me he's going as well
18:06rata_should I send a fn to an agent from a fn send to an agent?
18:06rata_*sent
18:06TimMcrata_: I don't think that's unusual.
18:06rata_there's no problem with retries and send?
18:08TimMcrata_: I believe that transactions are send-aware.
18:08rata_TimMc: so should I put the send in a dosync?
18:08TimMcerr
18:08TimMcI don't really know.
18:09brehautrata_: you only need to put send in a dosync if its related to atransaction on STM refs
18:09TimMcForget what I said about transactions...
18:09patrkrisrata_: depends on whether you need to do send an action to an agent, when the transaction completes
18:09brehautaside from that, i dont think there is any problem with sending an action to one agent from another
18:09TimMcAgent actions don't get retries, do they?
18:10TimMcThat's just transactions?
18:10raekcorrect
18:10patrkrisno, they're only sent when the transaction commits succesfully
18:10raekalso, sends from an agent action are held until the action completes successfully
18:11TimMcraek: Ah, that's right.
18:11rata_oh ok, thanks you all =)
18:11raek,(doc release-pending-sends)
18:11clojurebot"([]); Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent acti...
18:14rata_I forgot to say I'm sending an action to the same agent executing the action, but probably that doesn't change anything
18:15tsdhHi
18:16TimMcrata_: Correct.
18:16tsdhIs there a way to free the memoization cache of some memoized function explicitly?
18:16TimMctsdh: What for, to regain memory?
18:17brehauttdsh: not with the default implementation
18:18brehauttsdh: the implementation in The Joy of Clojure provides that feature (the cache is attached as metadata to the fn)
18:18brehautand you might find something in https://gist.github.com/747395 that is useful
18:18tsdhTimMc: I use memoize to circumvent expensive calculations that were done before. However, the calculations can produce a by-product, and when you want to have that, then the calculation has to be performed.
18:18TimMcA side effect?
18:19TimMcSounds like a bad idea.
18:19amalloytsdh: don't do it that way
18:19TimMctsdh: You'll make amalloy cry!
18:19TimMc(me too, for that matter)
18:19amalloy(defn expensive-function [args] (do stuff with args)) (defn cached-function [] (memoize expensive-function))
18:19tsdhTimMc: Yes. I calculate reachable vertices in graphs. A not too cheap side effect is the calculation of shortest paths.
18:20amalloythen whenever you want a new cache you can call cached-function and throw away your old cached version
18:20tsdhamalloy: Hm, that doesn't sound bad...
18:21TimMctsdh: Wait, are you actually using side effects, or do you just produce several results?
18:21amalloyie, (cached-function) will return a new version of expensive-function with an empty cache; keep that around for as long as you want
18:23tsdhWell, I think I should think about my design a bit. ;-)
18:23tsdhThanks for the hints.
18:26tsdhOne other thing. Can I create a dynamic binding without def-ing it before?
18:28amalloytsdh: kinda-sorta. see ##(doc with-local-vars)
18:28sexpbot⟹ "Macro ([name-vals-vec & body]); varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set"
18:29amalloyand also (declare foo) is basically like (def foo) without a value; creates a global var with no initial binding
18:29tsdhamalloy: Great
18:51TimMcLeiningen puts out reflection warnings for dependencies when I compile (with :warn-on-reflection) -- can anybody think of a situation where this would be desirable?
18:54powrtocTimMc, what having reflective calls??
18:56TimMcpowrtoc: I don't understand your question.
18:57powrtocTimMc, I didn't understand yours... are you asking when is having reflective calls desirable?
18:57powrtocas opposed to type-hinted ones?
18:57meshI want to make a function that translates [0 1 0 1] to [1 3], and [0 1 1] to [2 3] (so the indexes of the 1's), is this possible without writing the loop myself?
18:57TimMcNo, I'm asking about the desired scope of Leiningen's :warn-on-reflection option.
18:58hiredman,(doc indexed)
18:58clojurebotExcuse me?
18:58TimMcWHen enabled, it should clearly emit reflection warnings for the main source code. The question is, should it also emit warnings for reflection encountered in :dependencies.
18:58hiredman,(doc keep-indexed)
18:58clojurebot"([f coll]); Returns a lazy sequence of the non-nil results of (f index item). Note, this means false return values will be included. f must be free of side-effects."
18:59powrtocTimMc, ahh..... yes I think they might make sense... as a reflective call in a dependency is still a potential performance problem
19:01technomancyTimMc: if there is a way to do that I'm all ears
19:02TimMctechnomancy: It currently does that, as far as I can tell.
19:03powrtochmm... I have some problems with AOT/lein... when I build an uberjar featuring a proxy call, it bombs out with a NoClassDefFoundError for the proxied class
19:03powrtocI don't really understand it... I thought proxies were a runtime class
19:03amalloy&(keep-indexed #(and (= 1 %2) %1) [0 1 1] )
19:03sexpbot⟹ (false 1 2)
19:03technomancyTimMc: I mean if there's a way to get it turned on just for your project, I'm not aware of it
19:04TimMctechnomancy: Ah, got it.
19:04amalloy&(keep-indexed #(when (= 1 %2) %1) [0 1 1] )
19:04sexpbot⟹ (1 2)
19:04amalloymesh: ^ fleshes out hiredman's suggestion
19:04powrtocbut I need to gen-class the namespace so I can start it with a simple java -jar foo.jar
19:04TimMcOh right! Because the compiler goes back and forth and every which way when compiling, and leiningen can't turn warn-on-reflection on and off in the process.
19:05meshhiredman: amalloy: I think I have found something on the net about an indexed and index-filter function
19:05powrtocI'm not sure if this is an AOT issue or a leiningen issue
19:11technomancypowrtoc: depending on your needs you could look at using a shell-wrapper to launch; see leiningen's tutorial
19:14powrtoctechnomancy, Yeah I saw that... and not AOTing does solve the issue... but a shell wrapper forces the other end to use leiningen... and adds another moving part...
19:14powrtoctechnomancy, is this a known issue with AOT and proxy??
19:14technomancyyeah, it's a half-way solution
19:14technomancyI haven't heard of it, but I don't do much aot. are you on the latest lein?
19:14powrtoc1.4.0
19:15technomancyworth upgrading to 1.4.2, but I don't know if that'll fix it
19:15powrtocupdating now
19:16powrtocit looks like for some reason calls to proxy, even (proxy [Object] [] (toString [] "foo")) in an AOT'd namespace fail when built with lein
19:17technomancyif you can repro on the latest git, please open an issue
19:17powrtocI'm not sure if lein is stripping out the funny looking proxy classes from the build, or if it's a clojure thing
19:18powrtocbut at runtime clojure definitely expects to see a class on the classpath, and it aint there
19:18amalloyare you sure there are no stale class files from previous AOT runs causing conflicts?
19:18amalloythat usually winds up being the issue when someone has an AOT problem in #clojure
19:20powrtocamalloy, yeah, I clean each time
19:20powrtocand I think uberjar cleans automatically
19:20powrtoc(by default anyway)
19:23technomancythere was a brief period where leinigen removed non-project .class files, but this broke protocol usage since AOT semantics for protocols are different from everything else in clojure
19:25powrtoctechnomancy, amalloy: Here's the error and reproducible test case https://gist.github.com/863309
19:26amalloyooo i got a highlight on a leiningen bug. it's almost as if someone in #clojure thinks i know anything about leiningen (really i just ping technomancy when someone has an issue)
19:26powrtoctechnomancy, yeah, I saw that mentioned somewhere... but now that doesn't happen right?
19:27powrtochmmm 1.4.2 seems to have fixed it...
19:27powrtocneed to try it again on my real project
19:27powrtocto be sure
19:28powrtocyeah, that proxy class now exists... but 1.4.0 didn't generate it!
19:30technomancyyeah, the fix was released soon after 1.4.0
19:30technomancyluckily upgrading is really easy.
19:31powrtoctechnomancy, yeah you've done a reaalllyy nice job with the upgrade process etc..
19:32technomancyactually that wasn't me.
19:32technomancywas another seajure dude.
19:32powrtocwell you did a really fine thing in merging the patch! :-)
19:34tufflaxWhat does "(?i)" mean in this regex: (re-seq #"(?i)[fq].." "foo bar BAZ QUX quux") => ("foo" "QUX" "quu")
19:34amalloytufflax: turn on case insensititivity
19:35tufflaxok, thank you
19:35amalloy(also: disable counting of I and T characters cause they're so damn fun to type, apparently)
19:35powrtocleiningen is probably my favourite of all build tools on any platform... it's nice and simple, fosters a good workflow, and works
19:36powrtocmy only real problem with it is more a problem of managing dependencies and transative dependencies with clojars
19:36TimMcamalloy: Classic banananana error.
19:36hiredmanpowrtoc: and very easy to extend and hack on
19:36amalloyheh, indeed
19:37amalloyit's a good thing i didn't need to spell dakry too
19:37powrtochiredman, yeah that too!
19:37hiredmanI had a project that needed to generate a file in the META-INF directory in the gernated jar, so I just put a few lines in the project.clj that hooked the lein jar task
19:38powrtoctechnomancy, ok it works on my real project too! Thanks for your help... I didn't realise 1.4.2 was out
19:38powrtocuberjars r us!
19:38technomancy1.5.0 right around the corner; watch out
19:39powrtoctechnomancy, yeah, I saw the post
19:40powrtocdoes anyone here use either aleph or cljque?
19:41TimMctechnomancy: warn-on-reflection fix for repl will land on 1.5.0?
19:43technomancyTimMc: yeah; if you'd like to confirm it by running from git that'd be great.
19:43powrtocBasically I've written a stomp broker using raw netty... and I know to do so I've recreated a small part of aleph (and possibly cljque), but it was just easier to use netty early on as it's well documented compared to aleph etc...
19:45powrtocanyway, I was originally thinking I'd like to port it to aleph... but then I saw aleph was built around lamina but that cljque is a competing project/concept.... and cljque's RX inspiration makes me think it's a superior approach overall... what's the communities opinion>
19:45powrtoc?
19:51hiredmancljque has a horrible name
19:56technomancy"cudgel-k-you", like it's a threat.
19:58hiredmanbut I ma not super fond of aleph, I haven't used either, but I think I would lean towards cljque style if not cljque
20:02powrtochiredman, yeah it really does
20:04powrtochiredman, well I've recently done a lot of research into RX which is freakin' awesome (the best thing out of microsoft in years) and I'd love to see something like that gain traction with the clojure community
20:04powrtocI'm really just wondering which camp is the best to invest some time into
20:05powrtocproblem is that my server might actually be deployed in production at some point... so picking something really experimental might be a bad idea
20:06brehautpowrtoc: http://dev.clojure.org/display/design/Channels
20:06brehautWRT to the longer term
20:07danlarkinIn the same way that commute allows for "more concurrency" than alter, does alter allow for more than ref-set?
20:07hiredmanbrehaut: it's wiki, doesn't mean rich has commited to anything
20:07amalloydanlarkin: ref-set barely allows for any concurrency
20:07danlarkinbut why less than alter?
20:08amalloyi mean, it "allows for more", maybe, because the STM will let multiple threads set a ref if none of them read from it
20:08powrtocbrehaut, thanks for that... I've been trying to find that link again... note rich hickeys first comment... "no one should do anything without fully understanding RX"
20:09powrtocthat's my concern with aleph
20:09danlarkinI understand why commute > alter -- because you're telling the stm that operations are commutative, but alter makes no such guarantee
20:09amalloybut if you are reading from a ref, then writing to it based on that value, it seems horrible and evil to use ref-set
20:09amalloyand if you actually did read from it earlier in the transaction with @ref, i don't think you'd even gain anything from doing it that way
20:09hiredmancommute is an optimization, when in doubt use alter
20:10technomancyI'd be surprised if ref-set allowed for reordering behind the scenes.
20:10technomancywithout mentioning it at least.
20:11danlarkinok, now part two of my thinking,
20:12danlarkinlets say I have a transaction similar to this, (dosync (delete :dan) (add :dan2))
20:12danlarkineasy enough to do that with two alters
20:13danlarkinassuming delete and add modify the same ref
20:13danlarkinbut! how to represent that with one single alter
20:13hiredmanI don't follow
20:14danlarkinwell delete dissocs and add assocs, let's say
20:14hiredman(alter (ref ...) (fn [...] (-> ... (conj :dan2) (disj :dan))))
20:15danlarkinah
20:15danlarkinyes
20:15danlarkinthat's indeed what it would be
20:16danlarkinHm
20:16danlarkinI think I'm still confused about how alter can allow for more concurrency than ref-set
20:18amalloydanlarkin: you are coming at this from the wrong perspective. "allow more concurrency" is not really relevant here: the issue is that alter can be based on a pure function, while using ref-set puts concurrency code all over your program
20:19technomancydanlarkin: deref + ref-set introduces a window for a race condition
20:20danlarkinwhy is ref-setting a ref to 5 different than (alter r (fn [r] 5))
20:20amalloydanlarkin: it's not. they're both evil
20:21technomancyright; there's only a race if you're ref-setting to a value based upon an earlier read.
20:21hiredmana read outside of the transaction
20:21danlarkintechnomancy: not if you're doing it inside a transaction, which would be the only valid way to do that
20:21technomancyright; if you do it inside the transaction, it could result in a retry, not an invalid value.
20:22technomancyit's not _that_ racy.
20:22danlarkinI just don't see how it's any different than alter
20:23amalloydanlarkin: (dosync (let [x @foo] (ref-set foo (inc x)))) vs (dosync (alter x inc)). why would you ever do it the first way?
20:23amalloyer, alter foo inc, whatever
20:23danlarkinoh, you wouldn't for sure
20:23danlarkinbut, they're equivalent, right?
20:24amalloyfrom the computer's point of view? probably
20:24danlarkinin every single way, except for how the code reads
20:24amalloybut the code reads worse in so many different ways
20:24danlarkinI'm totally with you on that
20:25amalloyokay. so your question is "does one of these constructs have better performance"?
20:25danlarkinbasically
20:25amalloyafaik, no
20:26technomancythere's a slightly larger window in which a retry could be triggered
20:27danlarkintechnomancy: how, though
20:27amalloytechnomancy: i'm not sure about that...the retry will happen at the end of the dosync, not the end of the alter, right?
20:28technomancyI guess it's probably only practically larger if there's something going on between the deref and the set
20:29technomancyamalloy: I think it can retry as soon as it knows something is awry
21:06TimMctechnomancy: How do I get lein 1.5.0 shell script? (I've checked out the repo.)
21:07technomancyTimMc: it's in bin/lein
21:07TimMcThat script complains about missing deps.
21:08TimMc./bin/lein deps does too.
21:09technomancyright; you should be able to use your existing leiningen to get deps for it; see "Building" in the readme.
21:10technomancyif you have suggestions for a way to make that clearer I would like to hear it; for some reason it trips up a lot of people, but I am not sure what is confusing about it.
21:10TimMcOh! Ha, OK.
21:12TimMcI see it in the Building section now.
21:13tufflaxCoordinated change (as in refs are but atoms are not coordinated) does that mean that I am able to change several refs at the same time atomically? Have I understood this correctly?
21:13brehauttufflax: yes
21:13tufflaxok, good :)
21:13tufflaxthank you
21:15TimMctufflax: Just note that refs you only read from may be written to by another transaction.
21:15TimMc(though you will see a consistent state *during* a given transaction)
21:17TimMctechnomancy: I can confirm that lein master fixes the REPL warn-on-reflection problem. In fact, it also seems to turn warn-on-reflection *on* properly in the REPL, which it didn't before.
21:35tufflaxI'm a little bit confused by vars. Just, for the sake of argument say that I would like a counter of something, so I do (def counter 0). That creates a var right? But I can't use set-var! on it because that changes the root-binding. Should I use atoms or agents instead for that kind of thing? I'm not sure I have understood what vars should be used for exactly.
21:36brehauttufflax: you shouldnt really use vars as changable refs, an atom would be a much better choice in the context of a counter
21:36tufflaxok
21:36brehautvars have more of a role in the defining namespaces and such than as a 'variable' for your program (this is a terrible explaination. hopefully someone smarter can correct me)
21:37hiredmanvars provide storage for things in a namespace
21:37tufflaxhehe i think im beginning to understand... i read something like that in the doc for (binding ...)
21:38mecAs I understand it vars are for thread local changes. So if you only have one thread you could use vars, multiple threads use atoms
21:38hiredmanvars happen to provide dynamic thread-local rebinding
21:38hiredmanbut as of 1.3 not all vars do
21:38tufflaxBut in the example i had with a counter, even if i have a single thread, a var seem like a bad idea.
21:38tufflax...mec
21:38hiredmanright
21:39hiredmanoutside of developement vars should be treated as immutable
21:40tufflaxyeah ok, i think i have a pretty clear understanding now, thank you
21:43TimMc$findfn :foo true
21:43sexpbot[clojure.core/keyword? clojure.core/== clojure.core/distinct? clojure.core/boolean clojure.core/< clojure.core/= clojure.core/> clojure.core/>= clojure.core/<= clojure.core/ifn?]
21:45mechttps://gist.github.com/a5a7b994cdb3774e1843 these perform identically so is one more idiomatic, or even a builtin i've overlooked?
21:52tufflaxI though '!' in names are used to signify impurity/side effects, so how come 'send', for example, is not 'send!'?
21:53brehautmec: summation is much more simply (defn summation [f n] (apply + (map f (range n))))
21:54amalloybrehaut: i think he's just using summation as an example of his accumulate HOF
21:54mecyup
21:54brehautok sure
21:55brehautexcuse me while i grab this by the wrong end
21:55TimMctufflax: I think ! is used to distinguish between pure and impure versions of the same algorithm.
21:55TimMc...or when side effects are not otherwise obvious from the name.
21:55brehautmec: it smells to me like a wonky way of writing hylomorphism
21:56brehautbut hylomorphism is not idiomatic clojure
21:56tufflaxTimMc but 'send' doesn't seem more obvious than 'swap!' :P
21:56clojurebot:negative/num-1 + :positive/num-1 = :zero/zero
21:57brehautmec: where hylomorphism is an unfold into a fold, but we dont have an off the shelf unfold in clojure that i am aware of
21:57amalloymec: i don't 100% follow how accumulate works, but i don't think it's necessary for me to. i (a) hate acc3, (b) would wrote acc1 myself, (c) think acc2 is the best
21:58amalloyi'm not sure why you've hardcoded <= though. it seems to limit usefulness for no particular reason
22:00mecI don't think i've ever heard that term before
22:00amalloymec: it's what crazy haskellers/mathematicians say instead of unfold
22:00brehautamalloy: its not just unfold!
22:00mecwhat is unfold? :D
22:01amalloymec: unfold is the opposite of reduce
22:01amalloyhttps://gist.github.com/805583
22:02amalloydisclaimer: whenever i say something ending in "orphism", brehaut is the one who is actually right
22:02amalloybrehaut: map is a catamorphism, right?
22:03brehauti believe so
22:04brehautwait sorry, no catamorphism is fold
22:04brehautanamorphism is unfold
22:06mecamalloy: i agree that acc2 looks the best but would probably write 1 anyway
22:06tufflaxIf unold is the opposite of reduce, is fold and reduce the same thing? Also, I at first thought unfold was the same as unsplice (as in picking things out of a collection); I think I've heard it used that way before.
22:06amalloyyes, reduce and fold are synonymous
22:07amalloywell. there's foldr and foldl, which refer to whether you do (+ (+ (+ 1 2) 3) 4) or (+1 (+ 2 (+ 3 4)))
22:07amalloyand i can never remember which is which, but clojure uses the one that lets you consume the sequence lazily
22:08brehautthe lazy one is left
22:08brehautwhich i think is the former
22:08amalloycertainly the former is what clojure does
22:09amalloy&(reduce (partial list '+) [1 2 3 4])
22:09sexpbot⟹ (+ (+ (+ 1 2) 3) 4)
22:09tufflaxIs there some way to unsplice, so that I could do something like (+ (unsplice [1 2 3]))? There is not, right?
22:09amalloytufflax: certainly there is, because you haven't defined what unsplice means
22:10amalloyoh, do you just mean ##(apply + [1 2 3])?
22:10sexpbot⟹ 6
22:10tufflaxyes, but without apply
22:10amalloytufflax: you can do that inside of a macro, but in general it's a language construct that would lead to chaos if you could do it everywhere
22:10tufflaxhehe ok
22:10amalloy&(let [nums [1 2 3]] `(+ ~@nums))
22:10sexpbot⟹ (clojure.core/+ 1 2 3)
22:11brehautamalloy, tufflax: http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/origami.pdf more about folds and unfolds than you care to know ;)
22:12brehautit is of course written in mathskell
22:12brehautand that result is that its all greek to me
22:12amalloybrehaut: feh. i wrote fold and unfold; i neither need nor desire further information
22:12tufflaxBy the way, speaking of macros: No book I've read (Joy of Clojure or Programming Clojure) goes very deep into macros. Where can I learn more? I was thinking of reading "Let over lambda" or "on lisp" although they use CL. Do you think that the ideas in them apply to clojure?
22:13mecim not sure i understand unfold
22:13zippy314looking for some defmacro love. Here's a gist: https://gist.github.com/863513 the final call, i.e. using the macro returns: Can't use qualified name as parameter: my.namespace/this why?
22:13brehautmec: unfold generates a sequence
22:13mecfirst rule of macros, never use macros
22:13amalloytufflax: absolutely yes
22:13amalloyOn Lisp goes heavy into macros
22:14tufflaxok, hopefully I can extract the information without knowing CL
22:15brehauttufflax: the main difference in how they are used is that clojure uses macros as a light coating on the top of functions, whereas CL tends to be a bit more aggressive in its application
22:15tufflaxok, im not sure I understand what you mean though :)
22:16amalloyOL it spends a some time covering constructs that just aren't useful/necessary in clojure
22:16amalloywow that sentence is littered with wasted articles
22:17brehautin clojure, build your solution in terms of functions and data, and then at the end (maybe) add macros to make it a easier to use the API, rather than making the API out of macros
22:17brehautamalloy: vs everything i write which is littered with wasted words
22:18amalloybrehaut: that is of course sound advice, but you also imply that you shouldn't write macros for new syntactic constructs
22:18brehautamalloy: why would you, when you can just sugar domonad!
22:18amalloy*sob*
22:20brehautbut yes you are right, new syntax is ok
22:20amalloybrehaut: wrong again, new syntax is AWESOME!!!1
22:20brehautyou sure your not a C# developer?
22:21amalloyno grey area for you, is there
22:21brehautnone at all
22:24waxroseMorning every one. ( UGT ^_^ )
22:26phenom_does the STM still work this way: http://groups.google.com/group/clojure/browse_thread/thread/f6241aedb41d82df
22:27cky&(sort "foobar")
22:27sexpbot⟹ (\a \b \f \o \o \r)
22:32mecis there anything unfold can do that iterate cant?
22:32tufflaxbrehaut: http://pastebin.com/KcKAmC5S When you say that macros in Clojure is a light coating is sounds a little bit like the aphorisms there. But who am I to judge? :P
22:33amalloymec: no; as you can see i implemented unfold on top of iterate
22:33amalloybut neither is there anything map can do that lazy-seq can't do :P
22:33brehauttufflax: well there you go :)
22:33mecah true
22:36phenom_if I de-ref a ref in a dosync and another transaction changes it, my transaction will restart correct ?
22:37amalloyno, that's what ensure is for
22:40zippy314still looking for some defmacro/protocol love. Here's a gist: https://gist.github.com/863513 the final call at line 5, i.e. using the macro returns: Can't use qualified name as parameter: my.namespace/this why?
22:41amalloyzippy314: change them to ~'this
22:42amalloy&`[x 'x ~'x '~'x]
22:42sexpbot⟹ [clojure.core/x (quote clojure.core/x) x (quote x)]
22:42clojurebothttp://groups.google.com/group/clojure/browse_thread/thread/bba604cee3b232d9/28837d55525306d8?lnk=gst&amp;q=recursive+macroexpand#28837d55525306d8
22:42amalloywow, surprisingly relevant, clojurebot
22:49phenom_amalloy: im getting confused, can you explain this: http://pastie.org/1654199 ?
22:50zippy314amalloy: thanks.
22:53amalloyphenom_: the second transaction has successfully set the ref, but the first transaction is using the value it got when it first derefed
22:54amalloythe transaction always sees a consistent snapshot, but if you don't write to a ref you don't prevent it from being modified in the real world
22:54tomojso why does the first transaction not print "End"?
22:54phenom_it's retried !
22:54phenom_and i don understand why !!?!?
22:55phenom_am I crazy ?
22:55amalloyphenom_: you're not; the issue is probably that i don't actually know half the stuff i claim to know
22:55tomojI can't reproduce your output
22:55phenom_executing the same line again (the "do") prints it properly
22:56tomojoh, nevermind, reproduced
22:56phenom_I can reproduce it consistently even after jvm restarts
22:56phenom_tomoj: retry the do command and it'll work as expected
22:57amalloywait phenom_
22:57tomojadding an ensure seems to just make the ref-set transaction block
22:57phenom_same here
22:58amalloy.start is asynchronous; maybe you want to add a Thread/sleep between .start and dosycn
22:58mecIt's deffinitly starting before the ref-set because its printing 1 first
22:58amalloyi mean, you're testing something with a race condition here
22:58phenom_mec: exactly
22:58ossarehis there some way to make lein log what is happening? I'm doing a lein uberjar and it is stopping.
22:58ossarehjust hanging.
22:59amalloyphenom_: except that sometimes you say it works as expected. that sounds to me like a race condition
22:59phenom_the first run always is incorrect, every other run after that works
23:00mecThis is working as I understand it should, you dont need a transaction to read, but then you're reading a snapshot and it wont retry, but in a transaction a read will retry
23:01phenom_amalloy: and the thread sleep doesn't matter (just checked)
23:01phenom_so ... a read *within* a transaction will retry if the variable was modified outside the specific transaction ?
23:04meccorrect
23:05rata_is it ok to have an agent inside an atom? I always forget what mutable things I'm able to nest
23:05phenom_i think the literature is a little vague on this ... atleast the joy of clojure isn't specific on this in their write-skew section
23:06amalloyrata_: you *can* nest anything you want
23:06phenom_mec: so then what is the point of ensure?
23:06amalloyin practice having an agent wrapped with an atom sounds like a hanging offense
23:07meci've never heard of it before, but it appears to be a lock for the ref, so no other transaction can use it until you're done
23:07rata_amalloy: why?
23:07amalloyrata_: that was going to be my next question :P
23:08rata_amalloy: your question is why I'm doing it?
23:08amalloyyeah
23:10rata_I have a http server running simulations, each simulation goes into a map which is in an atom
23:10rata_an each simulation is an agent that runs that simulation
23:11rata_amalloy: ^
23:12amalloyinteresting
23:13amalloyi dunno, seems reasonable to me
23:15rata_good
23:15rata_agents are so cool
23:26tomojrata_: http requests trigger simulation starts?
23:26rata_tomoj: yes
23:26tomojand then requests can get status by checking the agents?
23:27rata_yes
23:32tomojneat
23:33amalloyrata_: incidentally i still think an atom around an agent is bad news. you have a *map* of agents within an atom, which seems less likely to be disastrous
23:34amalloybut exceptions abound for every rule, and i could well be wrong about (atom (agent foo))
23:35rata_amalloy: it's (atom {1 (agent foo), 2 (agent bar), ...})
23:35rata_where 1 and 2 are simulation ids
23:35amalloyright
23:35rata_does anyone have used protovis btw?
23:35rata_mmmmm bad english
23:36rata_whatever
23:36rata_have anyone used protovis?