#clojure logs

2011-07-12

00:13gstampA little gotcha... *ns* seems to point to clojure.core when you run as a gen-class compiled classfile.
00:45hiredmangstamp: why do you think it would be set to something else?
00:48hiredmanwhen you compile a file a dynamic binding is pushed for *ns*, and effectively is set! to a given namespace by ns or in-ns
00:48hiredmanthe set! value is popped off when compilation is complete
00:49hiredmanwhen you are running anywhere but in a repl *ns* is almost always clojure.core
02:32ihodescoolest piece of software i've recently used: VMWare Fusion.
03:49chitsubrAnyone know a way to get tab completion of clojure keywords in emacs?
03:56kumarshantanuchitsubr: autocomplete.el ?
03:56kumarshantanuchitsubr: but it works off a TAG file AFAICT
03:57chitsubrkumarshantanu: ah right. Thanks, I'll look around for tag files for clojure.
04:10kumarshantanuchitsubr: apparently the latest autocomplete.el already has the clojure.core tags
04:14chitsubrkumarshantanu: I will update my autocomplete.el then, thx
05:02shtutgartIs it correct to def things inside a defn?
05:03shtutgarte.g. (defn foo [x] (def bar x))
05:03lnostdal-laptopthat should be fine
05:05shtutgartit works, but is it idiomatic?
05:06lnostdal-laptophard to tell with no context
05:07Chousukethat's usually completely the wrong thing to do :/
05:08shtutgartIt's for building gui. Function creates form, and inner defs are widgets.
05:08Chousukeall defs are top level, and most of the time doing them from a function makes no sense (since you're not supposed to def the same var multiple times)
05:08Chousukeuse let for local variables
05:10Chousukethe only situation where defs from a function make sense is an "init" function that sets up your program/library and gets called exactly once (even then it's somewhat icky)
05:10lnostdal-laptopi guess you want them to stick around after the function ends then .. perhaps using a structure in a variable (atom/ref) defined only once would work too
05:10Chousukeavoid that too
05:10lnostdal-laptop..then setting that ref/atom
05:11Chousukejust return whatever you want to keep from the function
05:11lnostdal-laptopyes, return and set
05:12shtutgartI was using let, but I need access to widgets from other functions, with let they anyway have to be defined in the defn, so I'll be ended up with ALL my functions and widgets defined in the one let form, which is hard to read and understand
05:12Chousukein general, the number of functions *not* dealing with atoms or refs should be significantly higher than the number of functions that do have state.
05:13shtutgartChousuke: return all widgets from the function?
05:13Chousukeshtutgart: yes. in a container, if you have to
05:14Chousukeif you need access to other widgets, have the other functions return them
05:14Chousukethen collect it all together in one function
05:14Chousukeusing modifiable globals is brittle and unidiomatic. :/
05:15shtutgartBut then I will have all my namespaces with all my definitions wrapped in one bug and messy let form
05:15Chousukewhy?
05:15clojurebotwhy not?
05:15Chousukeclojurebot: shut up
05:15Chousuke:P
05:15clojurebotTitim gan éirí ort.
05:16shtutgartbecause I need access to widgets in other functions
05:16lnostdal-laptopyou could use a map structure bound to a let
05:16lnostdal-laptopin a let*
05:16Chousukeshtutgart: I don't understand what the problem is
05:16shtutgartlnostdal-laptop: map with widgets?
05:16lnostdal-laptopsure .. i guess they have IDs
05:17lnostdal-laptopid -> widget-instance .. and i like having stuff like this in a top-level global so my top-level function can return to the repl and i can inspect things freely .. there's no problem with this
05:17shtutgartbut... we already have namespaces for this purpose, why should I create another one map?
05:18shtutgartChousuke: ok. let me paste an example
05:18Chousukein that case you can do something like... (defn make-widget ....) (defn make-all-widgets ...) (def widgets (make-all-widgets))
05:25shtutgartsomething like this: http://paste.lisp.org/display/123219
05:26shtutgartalso note that I need forward declaration to define widgets in right order
05:28lnostdal-laptopi really don't understand why you do not use a map for this
05:28Chousukeyeah, a map would be fine
05:28shtutgartI can't see why to wrap widgets in another map. We already have namespaces! What's the profit of holding widgets in the map?
05:28Chousukethe profit is that you can pass them around easily
05:29shtutgartOne difference is tha i have to type (:widget *map*) instead of just widget
05:29Chousukeno globals
05:29Chousukeand you can destructure
05:29lnostdal-laptopit's easier to pass around?
05:29Chousukeso (let [{:keys [widget names here]} widgets] ...)
05:30shtutgartIf I use var-per-widget approach, I don't need destructing at all.
05:30Chousukeyes but then you have loads of vars that you can never garbage-collects :/
05:30Chousuke-s
05:31shtutgartHm, good point
05:32lnostdal-laptopwell, it's not like the widgets in the map disappear as if by magic either
05:33lnostdal-laptop(..and clojure has no support for weak hash-tables; if that'd be interesting in this context..)
05:34Chousukelnostdal-laptop: but you can just lose your reference to the map
05:34ChousukeI'm not saying def it into a var
05:35lnostdal-laptopsure, but that'd happen if he def'ed over his many vars also; the old bindings would be GCed
05:35lnostdal-laptop..not sure i'm using the proper terms her, but anyway
05:36Chousukeyeah but that's ugly
05:36Chousukeand not guaranteed to work anyway I think, at least in 1.3
05:36lnostdal-laptopit should work
05:36lnostdal-laptopbut this is beside the original point anyway
05:36Chousukeperhaps only for dynamic vars
05:37lnostdal-laptop..it'd be a bug in clojure if it didn't work, and even if it did work it isn't interesting..
05:37Chousukeno, it's not a bug. The behaviour will change in 1.3
05:37Chousukevars will be more like constants
05:37Chousukeso you can't just go ahead and def them again
05:37lnostdal-laptopi'm jusing 1.3 .. i know
05:37lnostdal-laptopusing*
05:38lnostdal-laptopof course you can def them again
05:39lnostdal-laptopthey are not constant; they are instead not dynamic by default
05:39lnostdal-laptop..IIRC
05:39lnostdal-laptopi can redefine plan unearmuffed vars for sure at least
05:39lnostdal-laptopplain*
05:39lnostdal-laptopbut forget this ....sheesh... it's not interesting in this context anyway .. :}
05:41shtutgarthm, then, what can you advice me about forward declaration? Should I write macro that first lets all widgets to nil? And what about bindings? Should I write another macro and renounce the use of bindings?
05:42Chousukeyou don't need a macro
05:42Chousuke(declare whatever you want)
05:42Chousuke:P
05:43ChousukeI'm still not sure that it's a good idea to def widgets globally but whatever :)
05:43shtutgartChousuke: I mean macro that will be automatically let all widgets to nil first
05:43lnostdal-laptopi wouldn't do that at all, shtutgart .. i'd use a single top-level dynamic ref-variable bound to a map.. whenever my top-level function returns i'd ref-set it
05:43Chousukeshtutgart: what for?
05:43lnostdal-laptop..and i'd using the binding form for the rest of the call tree
05:44Chousukeshtutgart: if you let them to nil you could just as well let them be the actual widget objects
05:45Chousukesince let bindings are lexical and constant, you can only "change" the binding by shadowing it
05:46shtutgartlnostdal-laptop: ok, I'll try it
05:47shtutgartChousuke: I want to define widgets in right order (think of html) and that requires some forward declaration, that's why i'm talking about letting to nil
05:54lnostdal-laptopshtutgart, http://paste.lisp.org/display/123220 .. something like this i think .. typed in a hurry tho
05:55lnostdal-laptop..i wonder if clj has something like prog1
05:58shtutgartlnostdal-laptop: thank you, i'll look into it
05:59bsteubershtutgart: I assume you use a java gui framework
06:00bsteuberso why not just use mutation to cennect the widgets?
06:00bsteubers/cenn/conn
06:00sexpbot<bsteuber> so why not just use mutation to connect the widgets?
06:00shtutgartbsteuber: it can't be done; constructors require parent widget
06:01bsteuberso let the parent first
06:02bsteuberor do you want to build all in one nice expression?
06:02bsteuberwhich framework is it?
06:02shtutgartyep
06:02shtutgartswt
06:03bsteuberoh didn't know
06:04bsteuberseems like you need a macro for that, with all the drawbacks macros have..
06:26shtutgartbsteuber: I already have macros here and there, so another one doesn't make much difference :)
06:29bsteuberlol
06:31bsteuberanother idea would be to not return swt objects immediately
06:31bsteuberbut rather have your widget functions build clojure data structures
06:31bsteuberthat get "compiled" to swt all at once
06:32bsteubermaybe that'd be cleaner than macro hell
06:37shtutgartbsteuber: hm, then user's action functions can also operate on clojure data structures, and framework will then generate setters calls for changed values (I guess I read about such approach somewhere on the clojrue google group)
06:39bsteubersth. like that
06:39bsteubermaybe I should've done the same for my swing wrapper ^^
06:40bsteuberwell I don't need to set parents most of the time, so I don't have your problem
06:40bsteuberbut a lot of other ones :)
06:43shtutgartno, Im talking not about parent, but about any changeable values. Like, your action-listener should be widgets-map -> widgets-map function, where widgets are immutable clojure records, and framework should take the diff of the input and output and generate setters for changed fields
06:43shtutgartthen holding widgets in a map makes complete sense, now I see
06:43bsteuberyes sounds elegant
06:44bsteuberbut you'll probably get other problems ^^
06:45shtutgartdefinitely! :)
06:45bsteuberI sometimes dream of starting a pure clojure gui framework
06:46bsteuberthat's lying on top of a pure clojure graphics/layouting framework
06:46bsteuberbut...
06:47shtutgartbtw, have you seen envydon?
06:49bsteuberno, what's that?
06:51shtutgarthm, I've lost the link, let me google that...
06:52gfrloggood morning europe
06:57shtutgartah, it calss indyvon: https://bitbucket.org/kryshen/indyvon
06:57shtutgart*it's called
07:03bsteubersounds interesting
07:34jcromartieindyvon looks like "immediate mode" giu
07:34jcromartiegui
08:03clgvwhat's the easiest way to find a given item in a nest clojure data structure consisting of hashmaps and vectors?
08:03clgvs/nest/nested/
08:03sexpbot<clgv> what's the easiest way to find a given item in a nested clojure data structure consisting of hashmaps and vectors?
08:08bsteuberclgv: maybe manually flatten it first
08:08clgvbsteuber: hm I guess I might not have to search for the items - seems I had some update-compilation problem
08:09clgvI should do "lein clean" more often
08:22bsteuberclgv: just for the fun of it: https://gist.github.com/1077871
08:23clgvbsteuber: the problem didnt vanish - so I'll give that one a try.
08:24bsteuberbot sure if you just want to check for existence or return the value or whatever
08:24bsteubernot :)
08:25clgvI have data I want to serialize and get a NotSerializableException - but in advance I have code that converts the deftypes to standard clojure data - seems somehow one or more objects of the deftype manage to hide somewhere they shouldnt
08:25bsteuberah
08:26clgvI dont find them manually
08:26bsteuberso then instead of true you'll want to return x
08:27clgvtrue. will be sufficient for the first check
08:28clgv(rec-find #(instance? bla.blubb.Mytype %) data-map) returns nil. so where are they hiding? :/
08:38clgvhumm serializing lazy sequences could be an issue... :/
08:38Hodappyes.
08:38clgvreally stupid mistake^^
08:38Hodapppsssh, it happens
08:38clgvguess I have to write that "eager" "map!" command now
08:39Hodapplike when I forget I'm on a remote server and I do a DHCP release
08:39clgvI needed it at least 5 times now, thats big enough as threshold ;)
08:39clgvHodapp: oh thats epic ;)
08:39bsteuberwyh exactly do you need to be eager?
08:39bsteubersome external resources involved?
08:40clgvbsteuber: so that the conversion takes place bevor the serialization - otherwise the lazyseq object is serialized with the uncoverted data it seems
08:42bsteuberone dorun not enough?
08:42bsteubererm doall
08:42clgvyes, I put a doall there now
08:42bsteuberwell that's probably not recursive
08:43CozeyWhat's a better keyword counterpart for a camelCasedName? :camelcasedname or :camel-cased-name
08:43digashblist
08:43clgvbut (doall (map ...)) is really lame. I just could write a different map command that just evaluates everything ;)
08:44babilenCozey: I would say :camel-cased-name -- but listen to the gurus here
08:44babilen(i.e. not me)
08:44Cozeyok:-)
08:44Cozeyit seems to be more readable
08:45Cozeyon the other hand leaving dashes out is not much less readable, and is less typing
08:45shtutgart`vote for :camel-cased-name
08:45babilentyping? use a proper editor that allows completion :)
08:49Cozeyi use one
08:53digashblist
09:17clgvmy eager do-map can be found here: http://pastebin.com/eyN0uzPB - I wrote it somehow similar to map. any comments on it?
09:19pdk(vec (map f colls)) :p
09:19pdkalso putting )'s on their own lines is usually bad form unlike with }'s in C
09:20clgvpdk: yeah ok. except formatting^^ It's my thing - you might reformat it as you please :P
09:20Chousukeno-one will like reading your code if you write it like that though
09:20clgv(vec (map f colls)) has syntactic and runtime overhead
09:21Chousukemmh
09:21Chousukeare you sure?
09:21pdkeveryone ends up letting the editor space stuff for them in the end with lisp anyway so just run it through autoformat after you're done writing it i guess
09:21tomojsyntactic overhead?!?
09:21ChousukeI mean, (def do-map (comp vec map))
09:21clgvI dont know an autoformat tool
09:21Chousukepdk: that's not an option if you're collaborating on something though
09:22shtutgart`Do you remember that Steve Egge's thread about saying "yes"? ;)
09:23Chousukethe runtime overhead for the one-line implementation of do-map is a couple extra short-lived objects.
09:23Chousukethe JVM excels at working with those.
09:23Chousukeso they're basically free.
09:24Chousukedoing it manually is a decent exercise I guess but not exactly efficient use of programmer-time :)
09:26clgvChousuke: well do-map was written in 5-10mins - so the programmer-time was reasonable ;)
09:26Chousukeclgv: that's pretty bad compared to the 2 seconds it took for me to write my version :P
09:27clgvChousuke: well I am currently measuring runtime difference ;)
09:29shtutgart`Hm. Is it right that we do not have a naming convention for globals? I've just spent 5 minutes to figure out where an IllegalArgumentException comes from, and finally discovered that I have local binding shadowing global var...
09:31Chousukeshtutgart`: most globals are supposed to be constants and as such don't need anything special
09:31lnostdal-laptoppdk, it'll indent horizontally allright, but the vertical space is lost
09:32Chousukerebindable globals are called *foo*
09:32shtutgart`Chousuke: I know. But such constant can also be atoms or refs.
09:33Chousukeshtutgart`: it's still a constant
09:33shtutgart`Chousuke: I know, but it's global!
09:33Chousukeshtutgart`: what does that matter?
09:33Chousukeshtutgart`: if it's a ref, its mutability is clear from how you use it anyway
09:34shtutgart`Chousuke: see my first message :) Well, likely it's just my inattention
09:35Chousukeof course, no-one will stop you if you really want to use some naming convention for globals
09:36lnostdal-laptopshtutgart`, perhaps you're using (let .. ) where (binding ..) should be used?
09:37lnostdal-laptop... and i think *this-is-the-style-for-dynamic-globals* and for the other more traditional globals there is no convention .. i'm -using-this-style-for-them-though-
09:38shtutgart`lnostdal-laptop: no, I just had local with the same name as var (and got confusing exception with no line number known)
09:38chouserin some lisps +this+ is used for globals
09:38lnostdal-laptopthat's constants, is it not, chouser ?
09:38shtutgart`-this-style- looks really better than +this+
09:38chouserlnostdal-laptop: oh, probably
09:39chouserbut in Clojure, global namespaced vars are used for all our functions too -- surely you're not going to put dashes around all of them?
09:39lnostdal-laptopin CL i used +this+ for constants, -this- for globals (only some CL implementations supported that tho; i.e. SBCL), and *this* for dynamic globals
09:39chouserthey're in no less danger of be shadowed than other vars
09:40lnostdal-laptophm, yeah, lisp-1
09:40clgvChousuke: for input colls of length 100 measuring over 100 repetions my do-map needs only 3/4 of vec+map. for colls of length 1,000,000 and 100 repititions do-map only need 60% of vec+map
09:41lnostdal-laptopuh, but since the naming style for vars and functions differ it'll be ok i guess
09:42shtutgart`chouser: right, but I can't remember any problems with functions (don't know why, maybe functions usually have more unique names (e.g. in my example i had var named files))
09:42shtutgart`lnostdal-laptop: agree
09:42lnostdal-laptopa-function -a-global- *a-dynamic-global* less chance of clashes there than in the a-function and a-global case
09:43shtutgart`but @-an-atom- is not so good; maybe @an-atom- or smth like?
09:43chousershtutgart`: I actually am more likely to have problems with functions, wanting to name locals things like str, map, vec, list...
09:45shtutgart`chouser: but there is naming conventions for such stuff (like s, m, v, lst, etc)
09:48shtutgart`although, even clojure.core doesn't follow this style regularly; e.g., assoc takes map, key and val, when update-in takes m and k
09:50pdkstick the- in front of everything
09:50pdkproblem solved!
09:54shtutgart`indeed it's a good idea
09:55chousershtutgart`: hm, I suppose that is a naming convention.
09:59shtutgart`chouser: never seen the-globals style in someone's code
09:59chousersorry, I was away. I meant those single-letter locals are a naming convention
10:01shtutgart`That's exactly what I mean
10:01chouseryes, I was agreeing
10:03shtutgart`ah, ok :) my english is not very good, I don't always understand what people mean
10:13jweiss_can someone recommend a way to take a zipper where the current loc is some arbitrary place in the tree, and return one whose loc is the root? (can either rebuild a new zipper with the root node, or repeatedly call up until you hit the root)
10:14jweiss_i'm not sure which one is more expensive
10:14jweiss_they both seem pretty inefficient actually
10:36whiddenAre there any issues/contexts with using send?
10:37whiddenThe reason I ask is that I'm getting a ThreadPoolExecutor$AbortPolicy.rejectedExecution exception.
10:41jweiss_i get the feeling i'm using zippers wrong, i keep wanting the node, but without the children - but i get the entire tree and end up with much larger data structures than i really need
10:42gfrlogthere isn't any jsonp middleware for ring is there?
10:42whiddenThe stacktrace I'm getting is here: git://gist.github.com/1078109.git
10:43whiddenhmmm better link is; https://gist.github.com/1078109
10:46cemerickIt's ironic that the ML thread discussing my survey results post, which talks about the ML going off the rails, has gone off the rails.
10:47parasebaWhat are the plans for c.c.swing-utils? is going to be converted to its own project? is there any successors I'm not aware of?
10:50shtutgart`paraseba: seesaw?
10:52ejacksoncemerick: humans - as if entropy alone weren't enough to ensure chaos.
10:54parasebashtutgart`: it seems a lot bigger
10:54shtutgart`it is
10:55mprenticedo you guys know of a function that works like clojure.xml/emit but will safely escape attribute values and string contents?
10:59mprenticejweiss_: i've been doing quite a bit of xml tree walking lately. you need help?
11:05sritchiehey all -- does anyone have an example of how to use gen-class to define a nested class?
11:08jweiss_mprentice: yeah, i guess what i'm missing is a way to get the node minus the children
11:09mprenticejweiss_: so just the tag name and the attributes?
11:09jweiss_mprentice: it's not an xml zipper, just a generic one
11:10jweiss_but yeah, that's the xml equivalent
11:11mprenticejweiss_: you can filter by (complement branch?)
11:12mprenticethat should get you all the children of the current node that are leaf nodes
11:12jweiss_mprentice: no, because in my zipper, all the nodes are branches
11:12jweiss_which is why i'm starting to think i may be doing it wrong
11:13jweiss_should a branch just have children and no other info of its own?
11:14mprenticejweiss_: not necessarily. but you do need to know the structure if it has other info. do you have an example?
11:16jweiss_mprentice, my structure is like this - a map where one of the keys is a list of children: {:name blah :description "hi there" :children [{:name "child1"} {:name "child2" ]}
11:17jweiss_i suppose i could just dissoc :children
11:17jweiss_but i thought there was some build-in zipper way to do this
11:21gtrak`so, say I have a clojure ring web-app, and I'm required to integrate a security framework to enable x509 and PKI, what's the least evil approach? I'm considering spring security but this would require deployment within a servlet container
11:30mprenticejweiss_: dissoc children sounds like the way
12:06parasebaseancorfield: Sean, I just added a new patch for JDBC-11. The patch is working for me, and I thing it's a pretty urgent issue
12:19jfkwJust attempted an install on Ubuntu Server 11.04 of clojure dependencies for use with Leiningen. I am finding it diffucult to pull in a jre/jdk without X on that system. Any suggestions or URL?
12:20semperosjfkw: you mean you're trying to use apt-get or aptitude to install a JDK?
12:23semperosif you want to use a JDK available within the Ubuntu repo's, you can do a "sudo aptitude search jdk" to see a list of available ones, then install the one you want
12:24semperosif you want to install the Sun/Oracle one, you can download the self-extracting installer here http://download.oracle.com/otn-pub/java/jdk/6u26-b03/jdk-6u26-linux-i586.bin
12:25semperosthis post, though old, provides instructions for installing Java using the installer: http://dhruba.name/2009/07/13/installing-java-scala-and-vim-support-on-linux/
12:26semperosjfkw: didn't see you dropped off
12:26semperosif you want to install the Sun/Oracle one, you can
12:26semperos download the self-extracting installer here
12:26semperos http://download.oracle.com/otn-pub/java/jdk/6u26-b03/jdk-6u26-linux-i586.bin
12:27semperosthis post, though old, provides instructions for
12:27semperos installing Java using the installer:
12:27semperos http://dhruba.name/2009/07/13/installing-java-scala-and-vim-support-on-linux/
12:27ckyYou can also add the "partner" repository in Ubuntu and add the sun-java6-jdk package.
12:28jfkwsemperos: and cky thanks, will check these out.
12:28technomancymaybe openjdk-6-jre-headless ?
12:29ckyjfkw: Oops, I missed seeing your "no X dependency" part. Please disregard my comment.
12:29ckyjfkw: technomancy's comment is better.
12:29amalloyjweiss_: isn't zip/root the way to get back to the root? you asked about that earlier
12:30amalloyand Chousuke, shtutgart`: (comp doall map) is going to be more efficient than (comp vec map), since apparently he cares about efficiency
12:31jfkwtechomancy: thanks openjdk-6-jre-headless will work well. I didn't realize it initially, but maven2 package is the one pulling in all of X probably through its own dependencies.
12:32jfkwIs it the right presumption that a system packaged maven2 commonly used? Or do I build a non-system maven{2,3} under my home directory?
12:43technomancyjfkw: yeah, maven2 has a huge pile of unneeded deps... by default it will pull in gcj, groovy, and rhino (!)
12:44technomancyI wouldn't bother building your own unless you want new features that aren't in apt yet
12:44gtrak`jfkw, you can download the maven binaries too
13:00clgv&(map (fn [_] (map rand (range 5))) (range 5))
13:00sexpbot⟹ ((0.0 0.8441228844049946 0.7772274956553189 0.7283555804898323 2.0675454024470383) (0.0 0.04178595345506553 0.192762651873303 2.786763908112922 0.8947957998984526) (0.0 0.6043441057133377 0.2693049014431528 1.1875086636781094 0.2383735279084469) (0.0 0.8743459153161... http://gist.github.com/1078419
13:01clgvwhy is the first entry always zero (0.0)?
13:02kumarshantanujfkw: are you trying to run Java as a daemon?
13:02clgvI guess I have to use repeatedly. but the behavior with map is odd, anyway
13:04cemerickclgv: because ##(rand 0) is always 0
13:04sexpbot⟹ 0.0
13:04zerokarmalefthiredman: is conduit able to connect with a password?
13:04clgvcemerick: lol right.^^
13:07khebbieMy first clojure code https://github.com/khebbie/PET - any comments?
13:08GamliHi all - I am new here in this IRC-channel and I have a question about the arguments of a "deftype".
13:08GamliIs it right that the arguments MUST NOT have hyphens since they are compiled as java classes?
13:08Gamlie.g. is it wrong if I declare a type as this:
13:08Gamli(deftype Cow [cows-phrase])
13:08Gamli?
13:08Gamliups - sorry about the 5 lines
13:08joegallokhebbie: (defn foo "docstring goes here" [] (do-some-stuff))
13:08amalloyGamli: hyphens are fine
13:08clgvnope. it is legal to use hyphens.
13:08joegallothat got me for a long time too
13:09amalloyit gets turned into cows_phrase
13:09amalloyyou can put ! and ? in there too - they get munged the same way functions=>classnames do
13:09khebbiejoegallo: You say i should adddocstrings?
13:09Gamliamalloy: but if i use it it always says that the field is not defined when it is an REPL-output
13:09joegallodc-create, db-insert and db-query-for-today have something that i think is probably intended to be a docstring, but instead is just a string in the body of the function
13:10amalloykhebbie: you have (some of) the docstrings in the wrong place
13:10joegalloexactly
13:10amalloyGamli: you'
13:10jfkwtechnomancy: gtrac kumarshantanum, I'm trying to configure a colleague's ubuntu laptop to experiment with clojure, and a spare ubuntu server to figure out the no-X dependency chain, which looks pretty grim once I pull in maven. I would definitely undertake building maven from source/bin to avoid the X dependencies.
13:10khebbieOk
13:10amalloyre probably using deftype wrong. do you want a type or a record?
13:10khebbieamalloy: Where
13:11amalloyeverywhere that joegallo just said :P
13:11khebbieOk
13:11technomancyjfkw: bummer; doesn't sound like fun. is it really worth all that hassle to avoid X?
13:11technomancyor is it a matter of principle at this point? =)
13:11joegallokhebbie: minor complaint -- closing parens should not be on their own line (some people disagree with that)
13:12technomancyjoegallo: some people are wrong
13:12amalloypeople who disagree are loons
13:12joegallohehehehe
13:12khebbieamalloy: Ok, im a c# guy so i kinda use them as }
13:13amalloyin his case though i can kinda see the point: to clarify that each if has no else branch. which leads me to....use when instead of if, granted that you want no else
13:13jfkwtechnomancy: both ;) If we use clojure, it would be deployed on dozens of servers, so avoiding the X dependency is essential IMHO to keep server management under control. I know it's going to be less than fun.
13:13technomancyjfkw: deployment != dev environment
13:13technomancyno reason to put mvn on your servers; all you need is a jre
13:13jfkwtechnomancy: Good point, deploy jars only.
13:13khebbieamalloy: Whats the diff between if and when?
13:14technomancy(or maybe a JDK if you want to run the CDT debugger server-side)
13:14amalloy&(doc when)
13:14sexpbot⟹ "Macro ([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."
13:14joegallokhebbie: matter of style, but you can do this (Class/forName "whatever")
13:14khebbieamalloy: Aha
13:15khebbieOk, well got something to work on then
13:15khebbieThx all
13:15amalloykhebbie: thinking of ) as } is a handicap to understanding. in C# (for example), "if" is a statement, while "+" is part of an expression. clojure has only expressions, so having *some* of your constructs get "special" ending-) and not all of them is confusing
13:15khebbieamalloy: Ok
13:17Gamliamalloy: this is somehow strange. it is all ok as long as i just use the types in code. but as soon as the REPL should print the result (I'm using CCW for eclipse) i gat the "No matching field found" exception
13:17joegallokhebbie: you might not need that Class/forName call at all, it looks like c.c.sql handles it for you https://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/sql/internal.clj#L84
13:18Gamliamalloy: was that for me? (the code/stacktrace comment)
13:18amalloyindeed
13:18khebbiejoegallo: Ok
13:19clgvGamli: post your code at pastebin.com or something ;)
13:19Gamliok - i'll put together a small example
13:21joegallokhebbie: you can combine those (:require) forms in your ns
13:21joegallofyi -- almost everything i've said has been just nitpicking, overall the code looks pretty good
13:22joegallomight want to look at sql/insert-values
13:23Gamliamalloy: hope it is ok to post code here
13:23Gamli(deftype Cow [cows-phrase])
13:23Gamli(defn run [] (Cow. "Moo I'm a Coo"))
13:23Gamliif i call "run" it throws the exception
13:23Gamliargs - again sorry for the 4 line *G*
13:23khebbiejoegallo: Yeah have been thinking bout insert-values
13:24amalloyit's probably complaining that it doesn't know how to print your bare type
13:24amalloyif you used defrecord (as i suggested), that comes with a lot of built-in features
13:24Gamlibut it works if i replace the hyphen with an underscore
13:24khebbiejoegallo: Hoping to work on it a bit more and build up queries in code
13:25amalloythat's pretty weird
13:25Gamliyeah - thats what I thought
13:25GamliI mean - I could just replace the hyphens but... you know
13:26amalloywhat clojure version?
13:26cemerickamalloy: it's a bug in core_print.clj; the print-method handler for types isn't munging field names.
13:26Gamliby the way - I'm using 1.2.0-alpha8
13:27amalloyGamli: i don't think 1.2.0 ever had eight alphas. maybe you mean 1.3>'
13:27Gamlicemerick: ah ok - so I just HAVE TO replace the field-names?
13:27cemerickcore_print.clj, line 246; throw in (namespace-munge fld) instead of just fld, and it works as it should
13:27Gamliamalloy: sorry, 1.3.0-alpha8
13:27cemerickGamli: At the moment; it's a bug, but only related to printing of the types. You almost certainly want to be using defrecord to start with though, as amalloy suggested.
13:27Gamlicemerick: ok - I'll try that
13:28cemerickGamli: in general, see: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
13:28unlogicAnyone uses emacs-clojure-vagrant?
13:29Gamliamalloy, cemerick: ok, I'll try both (changing the code and using defrecord). thx in advance :)
13:31amalloycemerick: it's a new-in-1.3 problem? i don't see it on 1.2.1
13:31Gamliamalloy: yeah a colleague said the same a minute ago to me :)
13:32cemerickamalloy: yeah; 1.2.x didn't have readable types/records
13:32amalloyoh, it's for the #user.Test[4] notation
13:33amalloyi thought that was just for print-dup, not for repl printing
13:33dnolenunlogic: I tried it, interesting but it's a pretty incredibly long install process.
13:33unlogicdnolen: well, I managed to go through that process but I kind of got no idea what to do next
13:34dnolenunlogic: what OS are you using?
13:34unlogicI logged to virtual machine via "vagrant ssh", but there is only lone unconfigured emacs
13:34unlogicI use ubuntu
13:35dnolenunlogic: yes, so ran into this as well. for some reason the .sh in the repo doesn't get run. I copied it into the VM, chmod u+x and ran it and then I had a working setup.
13:35cemerickbah, the compiler needs tweaks too
13:36unlogicdnolen: Oh, yeah, how do you copy files into the virtual machine? "vagrant scp" doesn't work for me)
13:36dnolenunlogic: copy and paste :)
13:36technomancyunlogic: the directory containing the Vagrantfile is mounted as /vagrant on the VM
13:36technomancyso if there were problems running the provisioning script, you can cd /vagrant && sudo clojure_emacs.sh
13:37unlogictechnomancy: Ah, I get it now:) Thanks
13:41Gamliamalloy, cemerick: I just tried out the 1.3.0-beta1 and it doesn't work either. so I'll go with your ideas (really this time)
13:41cemerickno one trusts poor ol' cemerick :-P
13:42unlogictechnomancy: OK, script has finished now. I see jark and lein have beein installedm, but emacs still looks virgin
13:42Gamlicemerick: did you state something about the beta1? if so, im sorry that i read over it ;)
13:43amalloycemerick: i doubt your previous statement
13:44whiddenIf I assoc a new key-val pair to a defrecord the type of the resulting value is still the original defrecord. Is this expected?
13:44cemerickamalloy: I'm being cheeky. :-)
13:44amalloycemerick: me too! observe how i was mistrusting you
13:44amalloywhidden: yes
13:44cemerickah, crap. I've been irc punk'd.
13:45amalloyi will frame this chat log and place it on my wall
13:45whiddenamalloy: fizzlesticks, guess i need another hat.
13:45unlogicI still don't quite get it: should I use this vagrant vm just to run swank and connect to it from emacs on my host OS? Or is it designed to hack everything inside?
13:45amalloy...hat?
13:46technomancyunlogic: the idea is it's self-contained
13:46technomancyunlogic: M-x package-updates will pull in the packages once you're inside emacs if the provisioning script didnt get them
13:49cemerickGamli, amalloy: the ticket to watch for the deftype field name issue, if you're so inclined: http://dev.clojure.org/jira/browse/CLJ-819
13:50whiddenWhy would one want to use a 'defrecord' over a hash map?
13:50unlogictechmonancy: Thanks a lot, finally got it working.
13:50amalloywhidden: good question. too many people use defrecord just because it feels OO
13:50amalloysee, eg, http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
13:51Gamlicemerick: thx - nice to see somone care about such stuff. its a real pain in the ass during development if you don't know where the error comes from :)
13:51whiddenamalloy: ooh its been updated.... :) thanks
13:52cemerickGamli: We generally try to man the counter decently around here. :-)
13:52mprenticehmm is there a clojars or maven repository for GATE (gate.ac.uk)?
13:53cemerickwhidden: I put the first version of it together when I was in a particularly interop state of mind.
13:54technomancymprentice: $ lein search gate 2 # => [uk.ac.gate/gate-core "6.0"] among others
13:54amalloycemerick: i can't think of a case when you need methods not specified by interfaces
13:54whiddenso the question i have is what is performance sensitive?
13:54amalloybut i assume such cases exist: have an example handy?
13:54Gamliamalloy: there are such cases
13:54amalloywhidden: code whose performance you, personally, care about
13:55whiddenamalloy: I care about all my code ;)
13:55amalloythen stop it :P
13:55Gamliamalloy: trying to put together some example
13:55cemerickamalloy: Client defines the API, or a library requires particular method names and signatures without providing an interface. You want to write the thing in Clojure. Thus, additional methods, and gen-class.
13:56amalloyoh, sure
13:56Gamliamalloy: here is the example -> what cemerick said ^^
13:56amalloyhaha
13:57cemerickwhidden: an example of "performance sensitive" is accessing slots in a hot loop. Maps will kill you, defrecords with :keyname accessors will get close to Java perf, and .field access *will* be Java perf.
13:58amalloycemerick: hah, my comment is awaiting moderation
13:59mprenticetechnomancy: ah, thanks! i don't have something setup right, i get maven error from lein plugin install lein-search 1.0.0-SNAPSHOT
13:59cemerickamalloy: where? on my blog?
13:59amalloyyeah, i posted it just now
13:59technomancymprentice: it's built-in to lein 1.6.1
13:59mprenticemmmk, i'm on 1.5.2. i'll try upgrading.
13:59cemerickamalloy: first time commenters are put in moderation. You'll go straight through next time.
14:00unlogictechnomancy: and the last question, sorry for wasting your time. is there a chance to run X application inside vagrant, or this OS image is terminal-only?
14:00amalloytechnomancy: i seem to have gotten a "development/hacking" version of lein, which refuses to upgrade itself. what do i need to do to get a stable one?
14:00technomancyamalloy: want to try my .debs?
14:01amalloyhey, if you need testers, sure
14:01amalloyif it breaks, i still have cake :P
14:01technomancygit fetch && git checkout 1.6.1 will upgrade your checkout though.
14:01technomancylemme see
14:01amalloytechnomancy: but i don't have a git checkout anywhere i can find, is my problem
14:01whiddencemerick: crap... I think I've painted myself into a corner. Time to use another color.
14:02amalloyi did a lein self-install, i'm pretty sure
14:02technomancyoh, you did a wget of bin/lein from master; I see
14:02amalloyyeah, probly
14:02technomancylemme know if these work for you: http://p.hagelb.org/lein-debs.tar
14:02technomancylightly-tested
14:03technomancyelse just rm it and wget from the stable branch
14:03amalloytechnomancy: to delete the existing version, just kill ~/bin/lein?
14:03technomancyright
14:04technomancyI've tested it on sid, but as long as you install the other debs in the tarball you should be fine on any relatively-recent apt system
14:05amalloytechnomancy: ugh. it wants me to install clojure 1.2 system-wide? i've been brainwashed too well to tolerate that
14:05technomancyoh bugger, yeah that's not going to work outside debian unstable/testing
14:05technomancyforgot about that part
14:06technomancyamalloy: as long as you consider it a user-level application, putting jars in /usr/share/java is just fine
14:06amalloytechnomancy: have you considered setting "stable" to the default branch for lein? might prevent more mistakes like mine
14:07technomancy"default branch"?
14:07amalloythe one that people see when they browse the repo
14:07clojurebotmax people is 317
14:07amalloyand also gets checked out by default in clones
14:07amalloy(not really nice to have the two of those conflated together)
14:07technomancyyeah, definitely don't want it for clones
14:07technomancythe readme on the master branch links to the stable branch; I think that's good enough
14:08scgilardiwell, easy enough to git checkout master after cloning
14:08amalloyyeah, probably
14:11jcromartieIs there a good solution for cross-thread var-binding/earmuffs? I really like the idea of something like CL's special vars... but once you throw a thread in the mix you can't use them that way.
14:11amalloyjcromartie: that changes in 1.3, i'm told
14:11jcromartieI mean maybe some kind of careful application of macros could do it?
14:11jcromartieor what
14:12amalloydoesn't seem worth the pain
14:12jcromartieI am thinking of things like web apps with *session* or *user* or *client* and things like that
14:13jcromartieI think Sandbar does something like that?
14:13technomancy(doc bound-fn)
14:13clojurebot"([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."
14:13hiredmanthose don't seem like thread locals, so why would you use threadlocal bindings for them?
14:14jcromartieI guess I am just wishing for CL's special vars
14:15jcromartiebut guess anything that might be used that way would probably not play well cross-thread anyway
14:15jcromartielike *in* or *out
14:15jcromartie*
14:17whiddentechnomancy: If I use lein swank to run/debug my code i get thread-pool exceptions, this also happens if I use lein run, but not if I use lein repl, using latest lein of course. Any ideas whe?
14:17whidden*why?
14:18technomancywhidden: I don't know. it works fine for me, but others have reported the same behaviour you're seeing.
14:18technomancyI don't have enough data to reproduce the problem.
14:18technomancyclojurebot: agent thread pool
14:18clojurebotthe agent thread pool is kind of a problem in Clojure, see http://tech.puredanger.com/2010/06/08/clojure-agent-thread-pools/ and http://p.hagelb.org/shutdown-agents.jpg
14:18technomancy^ is the root cause of the problem
14:19amalloytechnomancy: i don't get it, though. surely you're never calling shutdown-agents in lein?
14:19mdeboardwhidden: I had the same problem last night sir.
14:19technomancyamalloy: I have to
14:19scgilardijcromartie: for things that are (truly) jvm-wide you can use a var in a namespace bound to an atom and set its value with swap! or reset! when it should change.
14:19mdeboardwhidden: On a different project
14:19technomancyotherwise the process will never exit
14:20technomancyamalloy: this is after all the in-project code has finished, of course.
14:20mdeboardlol @ scumbag agents
14:20whidden<sigh>
14:20technomancyamalloy: but it only shuts down after the in-project code is "done" running
14:20amalloymakes sense, i guess
14:20whiddenmakes debugging a bit of a pain.
14:20technomancyin-project code needs to block on the main thread if it wants to keep running, otherwise there's no way to work around this Clojure bug
14:21whiddentechnomancy: hmm i guess I can do that.
14:21amalloytechnomancy: or start up some other non-daemon thread
14:21technomancyamalloy: that will keep it alive, but if it doesn't block then shutdown-agents will still run
14:22technomancyand there's bloody no mechanism for restarting the agent thread pool. grrrrrr
14:22amalloyinteresting
14:22technomancyit really does suck
14:22mdeboardsurprising too
14:22technomancysurprising it's gone this long without being addressed
14:22amalloyi was trying to imagine some mechanism for this when i was reading your ML thread, but didn't come up with any clever ideas
14:22technomancyit's Google Code issue 120, which tells you something about how long it's been ignored.
14:23amalloyexcept one that doesn't work because it involves making threads change daemon/non-daemon status
14:26mdeboardwhidden: By any chance, are you running in a VM? Virtualbox, vagrant, etc.?
14:26hiredmanclojurebot: scope?
14:26clojurebotscope is at http://paste.lisp.org/display/73838
14:26whiddenmdeboard: no... i'm doing a lot of dbus interactions through a java proxy :(
14:27technomancywhidden: you can block in your -main by using @(promise)
14:27technomancywhidden: swank already does that though, so no idea why it's still falling through to shutdown-agents
14:28whiddentechnomancy: I tried that and it still fails in the same place.
14:35mdeboardtechnomancy: fwiw I can reproduce the problem 100% of the time. Is there any reports or other data I can generate and put... somewhere to help diagnose?
14:35mdeboardAre there any*
14:36mdeboardMy error case was that I'd forked uh
14:37mdeboard4clojure.com to try my hand at implementing some UI tweaks I'd been whining about, I started up mongo and `lein run`, which both responded just fine. But when I tried to connect via the browser it threw the thread exceptions
14:37technomancymdeboard: maybe add a println to the point right before shutdown-agents is called in leiningen.compile/get-readable-form
14:38mdeboardtechnomancy: Will do, once I get home
14:39technomancycould also add one to swank.swank/start-server after the .join doseq
14:39technomancymaybe get-thread-list isn't finding your thread for whatever reason
14:56jcromartieHey, #clojure, thanks for not being jerks.
14:57jcromartie(after spending time in some *ahem* less civilized language/framework channels)
15:06Munksgaardihkhgkjgkugui
15:06Munksgaardi am horny
15:10parasebawhy is reduce implemented in terms of next instead of rest? Is it a performance optimization?
15:11parasebanext is "less lazy" than rest, since it needs to check if there are more elements remaining. Of course, reduce doesn't need to exploit the full lazyness, since is going to traverse all the seq
15:11amalloyparaseba: it's going to be calling seq anyway, so there's no point using rest-then-seq
15:13parasebaI had some buggy code, that worked with 1.2.1 but not with 1.3.0. It somehow depended on reduce getting only one element at a time
15:13parasebaI was curious about where that behavior changed, but I can't find it
15:14amalloythat sounds like a pretty hard bug to introduce
15:15parasebaamalloy: I was generating a lazy seq of "user actions", and then using reduce to process the seq as it happens
15:15parasebanow with 1.3.0 I need two events for the first call to the reducing function
15:16parasebabecause, of course, next needs to process 2 events. But I can't understand why it was working with 1.2.1
15:16amalloyhuh? why does it need to process two events?
15:17amalloythis doesn't sound at all related to rest/next
15:18dansi'm having trouble installing clojure-contrib, i get the error: Unable to find resource 'org.clojure:clojure:pom:1.2.0-master-SNAPSHOT' in repository clojure-snapshots (http://build.clojure.org/snapshots)
15:18danscan anyone help me on this?
15:18technomancydans: switch to version 1.2.0
15:18technomancyno sense in using a snapshot
15:18dansi've just pulled the master branch from the git, so i have to specify the version?
15:18amalloymight as well be 1.2.1 by now
15:18parasebaamalloy: because reduce does something like (recur (next s) f (first s)). So, first wont return until we have the first event, and next wont return until we have the second
15:18technomancydans: the master branch of what?
15:19dansthis is the procedure i've followed http://riddell.us/ClojureOnUbuntu.html
15:19technomancy=(
15:19amalloyblog posts get out of date very quickly
15:19dansgit clone git://github.com/richhickey/clojure-contrib.git
15:19technomancyclojurebot: getting started?
15:19clojurebotgetting started is http://www.assembla.com/wiki/show/clojure/Getting_Started
15:19technomancydans: try that instead
15:19dansalright, cheers
15:20technomancymany a prospective user has been befuddled by those dang riddell.us pages
15:20cemerickit still references github.com/richhickey — can't be too recent
15:20technomancyclojurebot: riddell.us is a great source of outdated, unnecessarily-complicated, and confusing instructions.
15:20clojurebotIn Ordnung
15:22scgilardiI'm not sure there is a 1.2.1 build of contrib. I've been using 1.2.1 of clojure with 1.2.0 of contrib.
15:22parasebaamalloy: if reduce used rest instead, that could return before the second event. I think...
15:23zakwilsonIt just came to mind that ClojureQL makes it very easy to ask for things that don't make any sense whatsoever, like a join between two different databases.
15:24amalloyscgilardi: there isn't, but he was having trouble resolving clojure, not contrib
15:24amalloyparaseba: yes, i suppose it could. interesting
15:25scgilardiamalloy: gotchya, thanks.
15:25dansClojure is unlike most language in that you don't generally install Clojure itself ?
15:26parasebaamalloy: I'm using reduce for something it's not intended, processing a seq as it gets produced. But, I can't find why it works before 1.3.0
15:26amalloyparaseba: but if you really don't care about more than one element at a time, you should use doseq or dorun/map
15:26cemerickdans: Generally, no. Clojure is "just" a Java library.
15:27parasebaamalloy: yes, but I'd be implementing reduce, exactly reduce, just that using doseq.
15:28parasebaamalloy: It's a swing app, all state is passed through events with this reduce
15:28parasebareduce seemed like the perfect choice for this
15:29parasebaeach even "handler" receives the previous state of the application, and produces a new state. Each element in the collection is a user "action"
15:29parasebabut ... it's broken ... reduce won't work ... it needs 2 events to start processing
15:29schauerlichcan you start off reduce with a null action?
15:30parasebaschauerlich: I could, I guess...
15:31parasebaand what's driving me crazy is, that it shouldn't work on 1.2.1, but it does. Can't find out why
15:31paraseba1.2.1 also uses next in reduce
15:31parasebamaybe some change in lazy-seq ... but can't find it
15:33hiredmanparaseba: I would definitely bring that up on the mailing list, seems like a big change in behavior
15:33babilendans: I would recommend to use leiningen -- there will even be Debian/Ubuntu packages soonish and it will make ease your life tremendously.
15:34parasebahiredman: good idea, I'll "reduce" this to a simple example that shows the behavior change
15:37dansbabilen: yes, im looking at that now (just got clojure running)
15:37dansplanning on trying out noir
15:40babilendans: That way you can just run "lein new ; lein repl
15:40babilendans: It also works well with vimclojure and/or swank if you use vim or emacs.
15:51dansyes babilen, im using vimclojure :)
15:54danbellclojurebot riddell.us
15:55danbellclojurebot: riddell.us?
15:55clojurebotriddell.us is a great source of outdated, unnecessarily-complicated, and confusing instructions.
15:55babilendans: You might be interested in https://github.com/autre/lein-vimclojure in that case
15:56dansthanks
16:07jcromartieyay for point-free style: (def name-sort (partial sort-by (comp last words)))
16:22mdeboardjcromartie: point-free?
16:25amalloymdeboard: (defn add-one [x] (+ 1 x)) has one "point", x. roughly, a named variable
16:25amalloy(def add-one (partial + 1)) achieves the same thing with no points
16:25mdeboardahh ok
16:25markskilbeckIs point-free better?
16:25amalloymeh
16:26Scriptorit's a haskell/(ML?) thing
16:26amalloy$google haskell point-free evolution
16:26sexpbotFirst out of 20300 results is: The Evolution of a Haskell Programmer
16:26sexpbothttp://www.willamette.edu/~fruehr/haskell/evolution.html
16:26technomancyI switched away from point-free when I realized I wasn't making high scores any more.
16:26markskilbeckDanke.
16:26Scriptorbasically all code is viewed as a graph, with edges being functions and actual variables being being nodes
16:26mdeboardI dunno point-free doesn't seem like consistent syntax
16:26Scriptornodes = points
16:26dansim trying to install leinigen, i have lein.sh chmodded and in my path, but im getting command not found
16:27mdeboardCan't you do like (+ 1 %) or something
16:27Scriptormdeboard: yea, it's way easier in haskell
16:27mdeboardI read it last night but have forgotten :(
16:27Scriptoraddone = (+ 1)
16:27technomancydans: forget to chmod?
16:27khebbieI am using clojure.contrib.sql's with-query-results
16:27dansno technomancy
16:27markskilbeckIf it's 'lein.sh' you'll have to call 'lein.sh', not 'lein', right?
16:27danschmod a+x lein.sh
16:28technomancythen it must not be on your path
16:28markskilbeckNvm.
16:28khebbieNow in the function where i use it i have to parse the resultset
16:28khebbieIs it possible to return the sequence, and parse in an outer scope
16:28technomancymarkskilbeck: naturally
16:35jcromartieof course point-free can just be code golf
16:35jcromartieit doesn't really help anybody to have a file full of defs with no arglists, ets.
16:35jcromartie(dec usability)
16:35sexpbot⟹ -1
16:36amalloytechnomancy: "naturally" except to a windows user
16:37technomancysure, I don't pretend to understand how windows users think.
16:38mdeboardlol
16:41amalloy(inc technomancy)
16:41sexpbot⟹ 12
16:49jweiss_anyone familiar with this class of problem. i'm using a tracing fn i wrote (based on clojure.contrib.trace but uses robert.hooke), but if i enable it in a function, tracing never happens, the hooks are not added. If i run the same sexp in the repl, the hooks get added and tracing works.
16:50jweiss_something strange about the repl or swank dealing with vars?
16:59jweiss_huh, a doall on the outer for doesn't force the inner for
16:59jweiss_that is... odd
16:59amalloythat is not at all odd :P
17:00jweiss_not sure how the 2nd item in the outer for gets consumed when the inner loop doesn't run
17:00jweiss_well it's odd when you're not totally used to thinking lazily
17:00amalloyyou built a lazy-seq of lazy-seqs
17:01amalloyincidentally, if you think the second item in the outer for depends on the first item of an inner for, you probably don't want to have multiple for's at all
17:01amalloypaste a snippet of some kind?
17:01jweiss_amalloy: right, i get it now. just not the kind of thing you'd expect from a non lazy nested loop
17:02jweiss_note to self. whenever the repl works and code inexplicably doesn't, THIS IS WHY
17:02jweiss_i'm wondering if having the repl implicitly force evaluation is worth it :)
17:02amalloyeg, the difference between ##(for [x (range 3)] (for [y (range 3)] [x y])) and ##(for [x (range 3) y (range 3)] [x y])
17:02sexpbot (for [x (range 3)] (for [y (range 3)] [x... ⟹ (([0 0] [0 1] [0 2]) ([1 0] [1 1] [1 2]) ([2 0] [2 1] [2 2]))
17:02sexpbot (for [x (range 3) y (range 3)] [x y]) ⟹ ([0 0] [0 1] [0 2] [1 0] [1 1] [1 2] [2 0] [2 1] [2 2])
17:03jweiss_amalloy: the outer for has a side effect that needs doing before each inner
17:04amalloywhoa. it seems unlikely that for will ever really do what you want
17:04jweiss_i suppose i could have used doseq
17:05jweiss_since enabling trace is side-effecty
17:14jaohi. what's the idiomatic way of adding a new key/value to a map only if the key is not already there (i.e., (if (:key m) m (assoc m :key val))?
17:17Deranderjao: I don't know if this is the idiomatic way to do it, but I tend to do: (merge {:mykey myvalue} some-other-map)
17:18jaoDerander, looks good enough. Thanks.
17:19Deranderjao: any time
17:23ibdknoxI'm looking for any feedback people might have on Noir as I'm thinking of release 1.1.0 soon
17:37danbellibdknox: dang, still haven't tried it out
17:37ibdknoxdanbell: get on it ;)
17:37ibdknoxhaha
17:38danbellha, yeah
17:38danbelli think everyone who uses clojure for web stuff has a half-featured version of noir
17:38ibdknoxI suspect so
17:38ibdknoxlol
17:39hiredmanclojurebot: ssa is http://wingolog.org/archives/2011/07/12/static-single-assignment-for-functional-programmers
17:39clojurebot'Sea, mhuise.
17:42ibdknoxit seems like all the "new" languages are getting bought by companies as of late, you guys think Clojure will get grabbed up?
17:45amalloyibdknox: what does noir "do"? the readme is just like "it's a framework"
17:45ibdknoxamalloy: essentially it's a series of convenience methods over compojure/hiccup
17:45ibdknoxwhat it does at a fundamental level is provide a single point for you to start building a website
17:45technomancyibdknox: more than just relevance you mean?
17:46ibdknoxtechnomancy: I think so, though I don't know the details of that relationship?
17:47dnolenibdknox: what else has really been "bought up" recently?
17:47kwertiiWhoa. Noir is awesome. I am one of those people who had half of Noir built manually on top of Ring in every site I made.
17:47ibdknoxamalloy: basically instead of trying to figure out how to do cookies or stateful sessions by cobbling bits together, it has a very simple API that brings all those little pieces together
17:48ibdknoxdnolen: ruby was essentially just acquired by heroku
17:48ibdknoxdnolen: joyent grabbed node.js (whose logo is truly awful now)
17:48amalloywhuuuuut, ruby bought by heroku? that sounds like complete nonsense, but i'm not at all ruby-aware
17:49ibdknoxamalloy: they just got matz
17:49kwertiiamalloy: they hired matz and several core guys. Heroku being a part of Salesforce.com.
17:49dnolenibdknox: Matz isn't leaving his other posts. and node.js isn't really a language tho right? It's a I/O programming framework.
17:49ibdknoxamalloy: if you have the architect, you essentially have the language
17:49Scriptor_Eh
17:49ibdknoxdnolen: fair, it's a platform I would argue
17:49kwertiiHeroku supports Clojure now. Maybe they'll hire Rich Hickey, too
17:49kwertiithey certainly seem to have more cash than they know what to do with
17:50Scriptor_If matz disagrees with them he wouldbt have a problem getting a job :)
17:50ibdknoxsalesforce is doing extremely well currently
17:50ibdknoxScriptor_: I didn't mean it as a bad thing or that they would "control" it per se
17:50kwertiiseems to be. Heroku cost them $212 _million_. Heroku is cool and all, but ....
17:50dnolenkwertii: ibdknox: also rhickey seems like a fairly independent fellow.
17:51kwertiidnolen: they'd drive a dumptruck full of money up to his house and say "hey, work on whatever you like, just let us put your name on our website..."
17:51ibdknoxdnolen: agreed
17:51dnolenkwertii: I'm sure he would decline. rhickey seems to prefer to work on his own terms.
17:52kwertiidnolen: they'd let him work on his own terms. (the "work on whatever you like" part.) it's a prestige thing for them. they're not going to be telling matz how to develop ruby.
17:52kwertiithey just want a trophy for their display case
17:53kwertiithis way, they can tell investors, "by the way, we have the author of Ruby on board..."
17:53ibdknoxlol, I'm not sure how far that would actually go with investors
17:53ibdknoxalso, I don't think they're looking for more money at this point ;)
17:54kwertiiibdknox: sadly, much farther than one would rationally expect :p
17:54dnolenkwertii: this all ties into a hype side of technologies which are not grounded in reality of the quality/robustness/generality of said technology.
17:54kwertiiit generalizes to business partners generally. the sales slime at any other big company that they would care to do business with will be impressed
17:54kwertiidnolen: yep, agree 100%.
17:55kwertiiwhy else would they pay matz when they can use his work for free anyway?
17:55ibdknoxdnolen: *cough* node *cough*
17:55kwertiiunfortunately, even we programmers need to eat
17:57kwertiihow much could they possibly be paying matz? 150k, 200k per year, tops. that's pocket change to Salesforce. well worth the price. they can impress people at power lunches all year for that fee.
17:58ibdknoxit could easily be more than that
17:59ibdknoxbut yes, it's chump change in the grand scheme of things
17:59dnolenkwertii: question is, how does all of this actually help Ruby or the programmers that use it?
18:00kwertiiaccording to Google Finance, Salesforce had annual revenue of $1.6 BILLION USD in FY 2010
18:00kwertiidnolen: well, matz gets to sit around and think about Ruby all day, without worrying about where his next meal will come from. but he was doing that anyway.
18:01technomancyhe'll get more opportunities to practice speaking English
18:01ibdknoxlol
18:02ibdknoxamalloy: Thanks for the correction! Any other thoughts?
18:04kwertiias a side note, I have been using Heroku for 7 months at work, and technically speaking, it's great. (not $212m great, but still very nice.) my only problem is that they nickel-and-dime you for every little addon, at exorbitant rates.
18:04ibdknoxkwertii: yeah, the pricing kills, especially when you compare it to the EC2 instance that they're running on
18:04ibdknoxlol
18:04ibdknoxI love the workflow, but can't justify the cost
18:04kwertiiibdknox: yep. seems great for the low end, testing ideas out phase, but when I hit upon something that works, it's getting moved to Amazon
18:06kwertiiI imagine that 50 Heroku clones will pop up over the next year or two and drive the margins down
18:09kwertiiGoogle App Engine would be great if they put some ease-of-use convenience layers on top of it. It's far too baroque to set up and get running for mass adoption
18:09kwertiibut Heroku... just push a Git repo and you're up.
18:20amalloyibdknox: not really. i've been enjoying learning/implementing cookies and such myself
18:21amalloyso not really excited about noir
18:21ibdknoxfair enough :)
18:32kwertiias a professional working coder, while it might be fun to mess around with writing my own cookie handler and such, I simply don't have time for that. So, for me, Noir is great.
18:32kwertiiI had got the idea to write something like it 5 times over the last year, but never got around to it.
18:39zakwilsonIs anybody here using clj-record? I'm wondering if I want to.
18:41kwertiiby the way, if anyone here is in the Santa Barbara, California area, we're having the first meeting of the SB Clojure Users Group at 6 PM today. All are welcome!
18:41digashblist
18:47zakwilsonclj-record seems to want each model to be its own namespace, the way ActiveRecord makes each its own class. I'm not sure this is Good. Namespaces are not classes.
18:48SushisourceSo, maybe someone can explain a weird problem I'm having that I don't understand
18:49SushisourceI'm trying to map a function that uploads nodes to a Neo4j database and index
18:49amalloynooooooo, map+side-effects=:(
18:49SushisourceYeah, I figured
18:49SushisourceMy clojure style needs workd
18:49zakwilson(doall (map ...)) works
18:50SushisourceYEah!
18:50SushisourceSee because it worked when I wrapped it in this debug macro
18:50SushisourceWhich I thought was strange
18:50gfrlogzakwilson: wouldn't doseq be nicer?
18:50SushisourceOkay, so now that I get that, what's the stylistically correct way to do this?
18:50zakwilsonVery possibly, but it's harder to turn that in to (doall (pmap ...)) when you decide you want it to be magically parallel.
18:51SushisourceI feel like a barely undertand transactions at all
18:51zakwilsonTransactions have nothing to do with this.
18:51SushisourceHence my feelings
18:51SushisourceLol
18:51zakwilsondoseq is an imperative-style thing that's a lot like map. It is probably the most idiomatic way to do side effects to everything in a sequence.
18:52SushisourceOkay, cool.
18:52SushisourceIf one were to make such an action parallel, which luckily I don't have to do, what would be the right approach there?
18:52gfrlogI like indicating side effects with the word do
18:52amalloyzakwilson: doall isn't really parallel to doseq because it holds onto the head. dorun is more like doseq
18:53zakwilsonmap returns a lazy sequence; the thing required to generate each element of it is not done until the value of that elemnet is requested.
18:53zakwilsondoall causes the whole sequence to be generated immediately
18:55SushisourceWelp, this totally works
18:55SushisourceThanks for the advice
18:55zakwilsonI had to look up dorun. I don't think I've ever used it. It is also a reasonable way to do this: the side effects are performed and the return sequence is discarded.
18:55gfrlogmaybe that's why I like doseq better
18:56SushisourceTo try to answer myself, if I wanted to parellelize this I'd probably need to use the Neo4j's REST api ro somesuch
18:56SushisourceSounds like effort
18:57zakwilsondoseq and dorun are the Right Thing if you don't need a return value. Not mingling side effects and things that return values is better style, so yeah, prefer doseq and dorun to doall for this.
18:57SushisourceCool, good to know
18:57zakwilsonYou're actively using Neo4j for stuff. Good. Maybe you can tell me what I should read to learn more about graph databases and when I might want to use them.
18:58SushisourceWell, right now I'm actually using it for a DnD character helper, of all things
18:59SushisourceIt parses in a whole damn lot of various feats/spells/etc/whatever
18:59SushisourceAnd makes links between things that have affects on other things
18:59SushisourceThen, if you want to make some particular spell or whatever the best it can possibly be, you do reverse traversal on things that reference it
19:00SushisourceAnd it saves you the time of wading through thousands of pages of books
19:00zakwilsonI get the feeling a graph database might be a better fit than a relational database for a lot of applications that involve a bunch of things well... relating to each other. I just haven't seen a good intro to graph databases article.
19:00SushisourceYeah, it really feels like that
19:00SushisourceI sat down and tried to do this with sqllite
19:00clojurebotCool story bro.
19:00SushisourceAnd I was like "shit, this is impossible"
19:02zakwilsonI'm building a pretty ordinary database-backed webapp and finding it really tedious to write a zillion joins for relationships like item belongs to user. I'm thinking about using clj-record, but ORM is an antipattern.
19:02zakwilsonAnd clj-record is at least ORM-like, even if it isn't making classes.
19:02ibdknoxzakwilson: store it as objects?
19:02zakwilsonthen it's hard to query
19:03ibdknoxyeah, it's pretty easy to build your own indexes for things you want to query on
19:03SushisourceI really can't speak from much experience yet, because I've just got into it for this, but it really seems like a much more intuitive way to manage complex relationships and searching through them
19:04SushisourceMy only complaint might be that the documentation is a little sparse
19:04dnolenSushisource: btw, this sounds like a problem that's a good fit for core.logic.
19:04zakwilsonThe thought of using a document store instead of a relational DB crossed my mind, but there really are a bunch of separate entities that relate to each other. Relations make sense. Graphs might make sense if I understood them. Documents/objects really don't.
19:05dnolenSushisource: you just load all your facts into memory and do your querying there, if you're feeling brave https://github.com/clojure/core.logic
19:05ibdknoxzakwilson: fair enough, I completely agree if there are lots of relationships then it doesn't make sense
19:06dnolenSushisource: basically you talking about an expert system, Prolog is great for building one quickly as long as your dataset can fit reasonably into memory.
19:07zakwilsonBut I think a graph DB might. I want to learn more about them without having to jump in head first, and google/wikipedia are failing me.
19:08SushisourceCool suggestions. My only hesitation of doing something in memory is that there is quite a lot of text attached to this stuff
19:08Rayneszakwilson: http://github.com/flatland/jiraph
19:09SushisourceThe other issue being that the information is parsed from plaintext, so I think my plan is to do it with one script that builds the graph, and another for searchign it
19:09Rayneszakwilson: http://jim.webber.name/2011/04/21/e2f48ace-7dba-4709-8600-f29da3491cb4.aspx is a fantastic introduction to graph databases.
19:10zakwilsonThanks.
19:10zakwilson(inc Raynes)
19:10sexpbot⟹ 5
19:13danbellwait does that work?
19:13danbell(inc zakwilson)
19:13sexpbot⟹ 1
19:13danbellfor showing it to me
19:18technomancyhehe: (in-ns 'safe.module.helper)
19:18technomancy(def i (safe.account/get-id :mysql-id 337))
19:18technomancy(def h (query i "date:[0000-01-01T00:00:00Z TO 1990-01-01T00:00:00Z]"))
19:18technomancy(def h2 (query i "date:[2011-03-22T00:00:00Z TO 2011-03-22T23:59:59Z"))
19:18technomancy(def pfs (set (map :packfile-name (concat h h2))))
19:18technomancy(defn parse-packfile-blob-name [packfile-name]
19:18technomancy (let [[account-uuid _ pf] (.split packfile-name "/")
19:18technomancy coll-id (clojure.string/join "-" (butlast (.split pf "-")))
19:18technomancy chunk-id (last (.split pf "-"))]
19:18technomancy [account-uuid coll-id chunk-id]))
19:18technomancy(doseq [p pfs]
19:18technomancy (apply safe.import.indexing/download-and-index (parse-packfile-blob-name p)))
19:18technomancydammit
19:19technomancyI meant to say https://github.com/jboner/akka/commit/554bb3eb293fe083dcc4fd0fcb8e0b23bd566e5b#L2R19
19:20Raynestechnomancy: Paste moar code. MOAR
19:21ibdknoxtechnomancy: wow...
19:21clojurebottechnomancy is to blame for all failures
19:21hiredmanclojurebot: botsnack
19:21clojurebotThanks! Can I have chocolate next time
19:22zakwilsonI recently updated leiningen. Now, when I run lein swank and try to create futures in the running program, I get java.util.concurrent.RejectedExecutionException
19:22technomancyI put some flood blocking stuff on ERC but I guess I didn't test it.
19:23technomancyhiredman: ANYWAY i think you will appreicate the github link
19:23ibdknoxtechnomancy: lol that page is over 15gb
19:23ibdknoxerr
19:23ibdknoxmb
19:23hiredmanclojurebot: regale us with tales of scala
19:23clojurebotthe scala compiler | is | <reply> see: http://harrah.github.com/browse/samples/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala.html#65760
19:23hiredmanclojurebot: tell me more about scala
19:23clojurebot{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
19:24hiredmanclojurebot: is there anything else I should know about scala?
19:24clojurebotScala often gets in the way when trying to write neat code -- seen in #scala
19:24hiredmanI see
19:24zakwilsonclojurebot: it seems you have some opinions on scala
19:24clojurebotscala is also<reply>"we are completely screwed on ==." -- seen in #scala
19:24zakwilsonclojurebot: should I use scala?
19:24clojurebotthe scala compiler | is | <reply> see: http://harrah.github.com/browse/samples/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala.html#65760
19:24hiredmanI should reall fix those factoids
19:26jweiss_any clojure libs out there for testing external apps? lazytest etc are really for testing clojure code. looking for a generic test runner
19:27zakwilsontechnomancy: can you tell me anything about lein swank and the above exception? I can't use futures, pmap and probably agents since upgrading leiningen.
19:27hiredmantechnomancy is feuding with the clojure runtime
19:28hiredmanyou may need to upgrade swank-clojure
19:28technomancyzakwilson: I just pushed out 1.3.2 this morning
19:28technomancyif you still have the problem then you are running into a bug that I cannot reproduce on my own machine =\
19:28technomancyclojurebot: agent thread pool?
19:28clojurebotthe agent thread pool is kind of a problem in Clojure, see http://tech.puredanger.com/2010/06/08/clojure-agent-thread-pools/ and http://p.hagelb.org/shutdown-agents.jpg
19:29technomancytrying to work around a shortcoming of clojure and it's not going so well
19:29zakwilson[swank-clojure "1.3.2"] is not being found by lein deps
19:30technomancyhmm... let me look again
19:30zakwilsonthanks
19:30technomancyhm; I hadn't regenerated the pom when I uploaded
19:31technomancytry again
19:32zakwilsonThat works now. Thanks.
19:32zakwilson(inc technomancy)
19:32sexpbot⟹ 13
19:33technomancygreat
19:34mdeboard``technomancy: Earlier you asked me to add a println to compile/get-readable-form right before shutdown-agents is called. What should I be printing?
19:34technomancymdeboard``: first try 1.3.2 and see if that fixes it
19:35mdeboard``clj 1.3.2?
19:35technomancyswank-clojure 1.3.2
19:38mdeboard``technomancy: I assume lein plugin install swank-clojure 1.3.2 will be sufficient? I don't need to uninstall the old one?
19:38mdeboard``s/assume/home
19:38mdeboard``hope*
19:39technomancytry it; if it doesn't work then try again with the old one deleted
19:39technomancyI'm not sure if the de-dupe goes by file modification time or by version number
19:43mdeboard``I actually needed to uninstall/reinstall lein anyway
19:45mdeboard``technomancy: :O!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19:45mdeboard``You beautiful bastard
19:45mdeboard``I am truly excite.
19:45mdeboard``technomancy, i am not disappoint
19:45mdeboard``in other words, it worked.
19:48mdeboard``(inc (for [x (technomancy amalloy)] x))
19:48sexpbot⟹ 1
19:48mdeboard``aw :(
19:48amalloylol
19:48amalloynobody's ever going to inc that user again
19:49mdeboard``,(inc (for [x (technomancy amalloy)] x))
19:49clojurebotjava.lang.Exception: Unable to resolve symbol: technomancy in this context
19:50amalloytechnomancy: want to apply yourself to me as a function, baby?
19:51mdeboard``,(inc (for [x (2 3)] x))
19:51clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
19:51mdeboard``fine
19:57gfrlog(inc (for [x (technomancy amalloy)] x))
19:57sexpbot⟹ 2
19:59mdeboard``is that even right
19:59gfrlogmdeboard``: it's incrementing the karma of a user called "(for [x (technomancy amalloy)] x)"
19:59gfrlogwho hasn't shown up in #clojure too often lately
20:00mdeboard``lol, I mean, the logic
20:00mdeboard``notionally
20:00gfrlogwell the fact that you have an unquoted list won't help
20:00mdeboard``ohright
20:00amalloyand inc'ing a list won't either
20:01gfrlog(doseq [x [technomancy amalloy]] (inc x)) is probably what you're wanting
20:01mdeboard``oic
20:01gfrlogin this fantasy-clojure world
20:01mdeboard``I'm having a clojure threesome in fantasy clojure world
20:01gfrlogI bet
20:02mdeboard``snuggled between two big soft parentheses
20:02gfrlogparentheses-pillows: worst lisp-gift ever?
20:05amalloygfrlog: i'm super-sad that i can't find those anywhere
20:06gfrlogmy wife has a body-pillow that could maybe be shaped as a paren
20:07gfrlognew project: ranking the ASCII punctuation marks by their value as a pillow-shape
20:08gfrlogamalloy: yeah googling for "ascii pillows" is quite disappointing
20:09mdeboard``should be googling for unicode pillows anyway
20:10amalloyi want one with "&#40;" on it so nobody knows my secret love of parens
20:11mdeboard``amalloy: You're among friends, you can come out of the clojet. No one will even notice your lisp.
20:11amalloyor "&#40; is #1 in my book"
20:13gfrlogparens are the path to the ultimate answer?
20:13gfrlog:/
20:14amalloy&(char 41)
20:14sexpbot⟹ \)
20:14amalloy&(char 42)
20:14sexpbot⟹ \*
20:21mudgehello, is it possible to call a macro from java?
20:22gfrlogwhy would you want to do that?
20:22mudgegfrlog: because my boss says I have to write in java but there's a clojure library I want to use in Java
20:22mudgegfrlog: and I am trying to call a clojure macro but I am getting a Wrong number of args error
20:23gfrlogwhat library is it?
20:23Scriptormudge: clojure macros take in clojure data structures for their arguments, so make sure that's what you're passing it
20:23mudgegfrlog: so I am calling the clojure functions from with Java, but now I need to call a macro
20:23hiredmanmacros take to implicit args &form and &env
20:23hiredmantwo
20:23hiredmanyou can't really call a macro
20:24hiredmanmudge: don't do that
20:24hiredmanit won't be what you want
20:24mudgeokay, well here is exactly what I am trying to do, I am trying to call prxml
20:24mudgefrom clojure.contrib.prxml
20:24mudgebut clojure.contrib.prxml prints to standar out
20:24mudgebut i want it to return a string
20:25mudgeso normally you wrap prxml with with-out-str, which is a macro
20:25mudgeso I am trying to figure out how to make prxml return a string in java
20:26gfrloghmm
20:26gfrlogif you're not allowed to write an inch of clojure code
20:26mudgegfrlog: i find out prxml contructs xml is nicer than using Java DOM stuff
20:26gfrlogthe first thing that comes to mind is pushing/popping thread bindings to set *out* to a string writer
20:27Scriptorwould there be any way to set *out* using java?
20:27Scriptor^^
20:27mudgeyea, anyway to set *out* ?
20:27gfrlog&(doc push-thread-bindings)
20:27sexpbotjava.lang.SecurityException: You tripped the alarm! push-thread-bindings is bad!
20:28gfrlogwut?
20:28gfrlog(dec sexpbot)
20:28sexpbot⟹ -1
20:28gfrloganyhow, I'm 96% sure push-thread-bindings and pop-thread-bindings will do the trick
20:29mudgegfrlog, i will take a look at it
20:29gfrlogmudge: the canonical example usage is the source for clojure.core/bindings
20:30Scriptor,(doc binding)
20:30clojurebot"([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."
20:30mudgeRT.var("clojure.contrib.prxml", "prxml").invoke("[:funny \"yes\"]") will call prxml, so just need to figure out how to set *out*
20:30gfrlogs/bindings/binding
20:30sexpbot<gfrlog> mudge: the canonical example usage is the source for clojure.core/binding
20:30mudgegfrlog: thanks, I'll check it out now
20:30Scriptordamn, binding is a macro too
20:30mudgeis there a way to call macros from java?
20:31gfrlogScriptor: yeah, that's why gotta push/pop manually. Presumably there could be an in-between function that's just like binding but takes a fn, but that's only helpful if these weird situations come up more often :)
20:32gfrlogit could be called clojure.core/binding*
20:32hiredmanmudge: you can't "call" macros
20:32Scriptormudge: you can always ask the mailing list, bigger audience there
20:32Scriptor(regarding the setting *out* part)
20:32Scriptormight be someone who's already done this
20:32hiredmanwhen you use a macro it is expanded by clojure's compiler and compiled in place
20:33gfrlogin the best case, it would mean you'd have to write an eensy bit of clojure code ;-)
20:33gfrlogwhich would presumably get you fired
20:33mudgehiredman: what terminology should I use for invoking a macro?
20:33amalloyyeah, calling a macro from java is unlikely to be an action that makes you happy
20:33hiredmanmudge: it's not a terminology thing, what you want to do is not possible
20:33hiredmanmudge: use push and pop as people have suggested
20:34mudgeyea, i don't want to get fired by actually writing any clojure but using libriaries in java is okay
20:34mudgehiredman: okay, thanks
20:34gfrlogdangit if this conversation goes on any longer I'll have to go write binding* myself.
20:34amalloygfrlog: it's not very nice as a non-macro
20:35gfrlogamalloy: it couldn't just take some pairs and a fn?
20:35amalloysure
20:35amalloythe need to take a fn is what's not very nice
20:35gfrlogwhich would be much nicer in weird-constraints-java-world
20:35gfrlogthan pushing and popping
20:35gfrlogoh wait
20:35gfrlogI'd be writing it in clojure
20:36Scriptormudge: you could make a case that you'd only need a tiny bit of clojure code (write it before-hand) and document it fully
20:36gfrlogwhich wouldn't do him any good
20:36Scriptorif it beats implementing the lib yourself
20:36gfrlog(defn call-macro [var & args] ...)
20:36mudgegfrlog: it's okay if you write it in clojure as long as I can call it from java
20:37gfrlogso you can use clojure code as long as you're not the author?
20:37mudgeScriptor: yes, thanks
20:37amalloyi think that if you tried to actually do that, you'd find that's not the rule :P
20:37mudgegfrlog: just can't use the clojure language, but I can use libraries in java
20:38Scriptorgfrlog: hmm, the boss might just want the jars or something, if he wrote the clojure that'd mean there'd be clojure source in the project
20:38gfrlogso I'd have to package it in a "library" for you?
20:38Scriptorwhich he doesn't want to have to find devs to maintain in the future
20:38mudgeScriptor: correct
20:39gfrlogI guess it's easy enough to "lein jar"
20:39gfrlogalright blastit now that we've gone through all this effort...
20:50gfrlogmudge: https://github.com/fredericksgary/binding-star
20:50gfrlogI put a jar in the downloads section if that's easier
20:51mudgethanks gfrlog!
20:52gfrlogmudge: you'll have to create a map with a var in it, but I imagine if you're mucking with all the RT stuff then you can probably figure that out
20:53mudgegfrlog: yea
20:54mudgegfrlog: i think i know how to use it, trying it
20:56jst\list
20:56jstoh, ffs
20:57jstAlright, I have a question about Clojure that bothers the hell out of me.
20:57jstWho's up to the challenge?
20:57jcromartieok
20:57amalloyanyone?
20:57clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
20:58amalloyi think it's hilarious that anyone would think that depending on gfrlog's ten-second-to-write, never-going-to-be-maintained library is deemed better than writing two lines of clojure yourself, mudge
20:58jstAlright, why do the bindings in (let ...) need to come in form of a vector?
20:58Scriptorjst: it's not quite a vector
20:58jcromartiereally, that's it?
20:58amalloyjst: the alternative being?
20:58gfrlog(inc amalloy)
20:58sexpbot⟹ 15
20:58amalloyScriptor: yes it is
20:58jst(let (x 1) 1) for example
20:58jstA list
20:59Scriptorjst: ok, so it's a vector, but the syntax was chosen to visually separate the bindings from the actual code
20:59amalloyjst: to reduce the cognitive overload on parens
20:59amalloyso that (x 1) can (almost) always mean "i'm calling x as a function"
20:59amalloyrather than having to parse the surrounding code to decide what the parens mean this time
21:00mudgeamalloy: yes, I think I am actually just going to write his clojure code in java to do the same thing
21:00amalloybut there's no technical reason
21:00jcromartiegenerally (fn-or-macro [bindings or arglist] ...)
21:00mudgeamalloy: yes, in general it is dumb
21:00amalloymudge: last was directed at jst
21:00mudgeamalloy: ah, okay
21:00jstI'm just confused by all the different types of braces.
21:00Scriptorif I have a jar in my lib/ folder, how do I go about figuring out what to actually import?
21:00amalloy(defmacro cl-let [argvec & body] `(let ~(vec argvec) ~@body))
21:01jcromartiejst: fair enough... there are a lot in clojure
21:01Scriptorevery combination I've tried so far has returned ClassNotFound
21:01jcromartiehowever almost all of them are just sugar
21:01jstBut thanks! You, guys, helped.
21:02gfrlogmudge: and I'll probably delete that github repo the next time I'm reminded of its existence ;-)
21:02Scriptorgfrlog: remember *bind*?
21:02Scriptor* bind*
21:02gfrlogScriptor: I have to forget it first
21:04Scriptorso, to add a little more detail to my question, I have netflix-java-client-2.1.2.jar under lib/, the project's name is clj-netflix
21:05Scriptorwhat symbol name would I have to use to :use/import it?
21:05jst\quit
21:05jstffs
21:05amalloyScriptor: you need to figure out what's in the jar. there's no global answer
21:05mudgegfrlog: okay, i got it
21:05gfrlogjar -tf
21:06mudgenow I am wondering how to create a clojure map in java
21:06amalloyif the jar has a com.foo.netflix.Server class you want to use, you'll have to import that
21:06gfrlogmudge: I would try creating a java map first to see if it takes that
21:06mudgegfrlog, okay
21:07gfrlogelse, the api on the clojure map classes might be easy enough
21:07gfrlogor wait
21:07gfrlogjust call hash-map
21:07gfrlog,(hash-map (var inc) "wut")
21:07clojurebot{#'clojure.core/inc "wut"}
21:08mudgegfrlog, okay, thanks
21:08gfrlogI guess there should have been an alternate signature that takes a var, value, and fn, for the most common use case, but I refuse to edit that project any further :P
21:09Scriptoramalloy: no matter what the name of the class, it's prepended with my project's name, right?
21:09Scriptorlike my-project.com.foo.netflix
21:09amalloyuh, no
21:10gfrlogScriptor: not if it's in a java jar
21:10mudgegfrlog, that's fine, thanks
21:10Scriptorah
21:10gfrlogScriptor: you import by class name, like you do in java
21:11Scriptor"like you do in java" heh...about that
21:12mudgewait, can't I just do this to get the *out* variable: Var out = RT.var("clojure.core", "*out*");
21:12gfrlogprobably
21:13gfrlogI've never used clojure from java, that's the only reason I hesitate
21:13gfrloggonna just set it directly?
21:15cemericktechnomancy: did I just see a github link where unicode arrows work in scala case clauses?
21:16mudgegfrlog: i don't know, when I call RT.var("clojure.contrib.prxml", "prxml").invoke("[:p \"data\"]") it does not print to standard out like it should so I am confused
21:19amalloymudge: well that won't work anyway, because prxml wants a vector, not a string that looks kinda like a vector
21:21mudgehmm... now I am trying this: RT.var("clojure.core", "print").invoke("data to print")
21:21mudgebut it doesn't go to standard out
21:21amalloyprintln
21:21mudgesomehow I need to connect clojure with standard out, connect *out* with System.out
21:21amalloyprint doesn't flush the buffer
21:21Scriptoramalloy, gfrlog: thanks guys!
21:22mudgeamalloy: is there a clojure function that flushes the buffer?
21:22gfrlogScriptor: yessir
21:23gfrlogI think you can call .flush on *out*
21:23amalloyprintln
21:23amalloyor flush
21:23amalloyor .flush
21:23cemerickOMG, it's true: http://scala-programming-language.1934581.n4.nabble.com/More-unicode-alternatives-for-ASCII-operators-td2008146.html
21:23cemerickold news, but I had no idea
21:25mudgeamalloy, I'll try flush
21:25pdkunicode icons for set operations would be neat
21:25pdkdoesn't forth already use special symbols for those sorts of ops
21:26cemerickNeat, yet entirely impractical.
21:26mudgeamalloy: flush worked!!!!!!!!!
21:26amalloy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21:26gfrloggo potty-training
21:27mudgeamalloy: haha
21:27mudgeso now I will try prxml with flushing
21:30mudgeprxml works goes to standard out!!!!! but it expects a vector ooop!
21:33gfrlogclojure from java: worse than normal-java?
21:34chouserthat's if the Clojure is doing nothing to help.
21:35chouserIt's fairly easy to write Clojure that allows completely clean, idiomatic Java to work with it.
21:36chousermudge: did you figure out how to bind *out* to what you want?
21:36mudgeyes, I think it is best if I wrote a Clojure utility library and use those from Java
21:36gfrlogmudge: well good luck finding a new job ;-)
21:37mudgegfrlog, yes, i probably won't do it because of that
21:37mudgei probably will find another job after my current project
21:37mudgejust want to finish my current project
21:39mudgechouser: i think that I can do it but I haven't done it
21:39mudgeI want to use prxml in java but I realized I need to make vectors in java
21:39mudgeand I am not sure if it is worth it
21:39edw`Anyone here used Noir with Json POST requests?
21:40amalloyRT.var("clojure.core", "eval").invoke(RT.var("clojure.core", "read").invoke("(prxml [:a \"data\"])")); // no clojure, just java!
21:42mudgeamalloy: thanks, I think I can use "eval" to parse the vector string literals into real vectors for prxml --- so I can still use the nice clojure vector syntax for prxml
21:42jweiss_trying to make a component of an assert macro that takes a form and returns the form with the locally bound vars replaced with their values. thought a zipper might help, is there a zipper out there that walks clojure expressions?
21:43jweiss_seq-zip doesn't descend into vector binding forms for instance
21:43amalloyjweiss_: bindings are gonna kill you anyway
21:43jweiss_amalloy: what do you mean?
21:43amalloy(let [x 1] (assert (= 1 (let [x 5] x))))
21:44amalloyx will be 1 in the &env that assert gets passed
21:44jweiss_amalloy: ah well, this is just for informational logging, doesn't have to be perfect
21:44amalloythen just use postwalk-replace
21:44jweiss_k
21:45chouseramalloy: why not stick the binding in the clojure string along with the prxml and vector literals?
21:45gfrlogand that's how you call a macro from java
21:46chouseryou might consider writing some Clojure code to make it all more palatable from Java
21:47amalloychouser: sure, once you're going with read and eval, you might as well write the whole thing in clojure
21:47chouserwait, this is all going to suck
21:47amalloybut this isn't really my good suggestion
21:47chouseryeah, you'll have a giant string (with clumsily escaped double-quotes, probably) for your literal maps and vectors
21:48chouseryou'd be much better off with some kind of fluid builder API in Java, I think, than trying to use prxml
21:48gfrlogchouser: hash-map and vector would be decent, wouldn't they?
21:48mudgeI like the idea of just using eval for the literal vectors and maps
21:48chouseror better yet, write your code in Clojure and compile it ahead of time.
21:48amalloyaugh if i'd known you would like the suggestion i never would have made it
21:49amalloyit is a terrible idea
21:49mudgechouser: the reason I don't just write in clojure is because my boss wants me to write in java
21:50amalloythen he won't take kindly to "clojure encased in java strings"
21:50mudgebut I could use clojure and clojure.contrib as java libraries
21:50amalloyit has all the disadvantages of clojure and none of the advantages
21:50gfrlogamalloy: that's about what I was thinking when I said "worse than normal-java"
21:50mudgeamalloy: that's why I just like the idea of using eval for vectors
21:50mudgeor maybe for maps too
21:50gfrlogmudge: call the vector function?
21:51gfrlog,(vector :foo :foo :foo :foo)
21:51clojurebot[:foo :foo :foo :foo]
21:51mudgegfrlog: oh yea, good idea
21:51amalloyseriously whatever java api you want to use will be easier than this
21:51gfrlogyou could even write yourself a helper function so your java code is vector(hashmap(...) ....)
22:05mudgewhen i write RT.var("clojure.core", "eval").invoke(RT.var("clojure.core", "read").invoke("(prxml [:a \"data\"])"));
22:06mudgeI get java.lang.ClassCastException: java.lang.String cannot be cast to java.io.PushbackReader
22:12mudgeah, amalloy, read-string works: RT.var("clojure.core", "eval").invoke(RT.var("clojure.core", "read-string").invoke("(clojure.contrib.prxml/prxml [:a \"data\"])")); // no clojure, just java!
22:15amalloyif that code ever makes it into production i will kill myself for suggesting it. no pressure
22:15amalloyanyway, i'm headed home. best of luck, i guess
22:16cemericksomeone needs to talk me down from posting a Scala linkbait post
22:17cemerickthat is, it's entirely unproductive :-( ; but, I don't think I can help myself
22:18Scriptorwasn't there a clojure-lounge or something a while back?
22:19cemerickThere's #clojure-casual, but it's fundamentally unpopulated.
22:22Scriptorcemerick: post it! I've found Scala reading to be pretty interesting
22:22Scriptorsome stuff can still be relevant to clojure
22:38hiredman,scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
22:38clojurebotAny = 1
22:39SushisourceSo, if I want to apply my function that takes two parameters to every combination of two items in a sequence, what's the pretty way to do that?
22:42cemerickhiredman: can't believe you sullied clojurebot like that
22:43jhicknerhi all, i have a question about idiomatic clojure when dealing with app state
22:43jhickneris it good form to use a ref or atom even when you don't need concurrency? vs just def'ing repeatedly?
22:44hiredmanthe untyped λ calculus is the untyped λ calculus
22:46Scriptorjhickner: if you find yourself def'ing repeatedly why not use let?
22:47hiredmandef repeatedly is always wrong
22:48jhicknerso if you need to alter something, you should use a ref or an atom even if it's single threaded?
22:48hiredmandepends
22:48jhickner@Scriptor: it's not localized to just one function, it's a state object that's used in a few places
22:48amalloySushisource: depends what you mean by "every combination"
22:48hiredmando you reallt need to alter something?
22:49jhicknerit's a list of connected clients (to an aleph websocket server) and what group they're part of
22:50jhickneri use a map of group ids to vectors of aleph channels to do things like send messages to a particular group
22:50tomojI use an atom for that
22:51tomojthough I haven't thought about it much
22:51jhickneryeah I don't know if there's a better way. an atom makes more sense than a ref though I agree
22:52amalloySushisource: ie, what would (my-cool-function + [1 2 3 4]) return? [3 7]? [4 5 5 6]?
22:54jhicknerok I think I'll use an atom for now. thanks guys
23:13chrissbxIs there another way than using a fn to bind multiple variables to values "in parallel", unlike the sequential way "let" does it?
23:14amalloy&(let [[x y] [1 2]] (+ x y))
23:14sexpbot⟹ 3
23:14chrissbxah
23:14chrissbxgood point
23:15chrissbxI guess I should ask whether that's slower, though, i.e. heap-allocating a vector.
23:15amalloyclojurebot: let* is ##(let [[x y] [1 2]] (+ x y))
23:15sexpbot⟹ 3
23:15clojurebotOk.
23:15chrissbx(but I guess an fn would do that, too)
23:16tomojclojurebot: let*?
23:16clojurebotlet* is ##(let [[x y] [1 2]] (+ x y))
23:16sexpbot⟹ 3
23:16tomoj:D
23:16chrissbxNote that these let and let* are the other way around in Scheme.
23:16amalloychrissbx: yeah, i know
23:16amalloybut when someone asks about it they always mention let*
23:17chrissbxI see
23:18chrissbxNow, actually the Scheme let is like let* and unlike a lambda, and unlike your solution, in that variable and expressions are together.
23:18chrissbx)Just nitpicking :)
23:18chrissbx(
23:18amalloyso write a macro
23:21chrissbxHm. I'm translating Scheme to Clojure; such a macro would be easy for my translation process, but not sure people would like that.
23:23chrissbx(I could turn a Scheme let into a Clojure let as long as it doesn't use previous left-side variable names on the right side. Looses the meaning of "you (human reader) don't need to consider previous variables on the left when reading the expressions on the right",
23:24chrissbxbut Clojurians would feel at home.)
23:31Scriptorchrissbx: as in, a scheme->clojure converter?
23:33chrissbxScriptor: yes
23:33jcromartiechrissbx: actually that left-right let issue is not an issues
23:33jcromartienot an issue
23:34Scriptorchrissbx: cool, what're you using for parsing?
23:34jcromartie,(let [x 1 y x z y] z)
23:34clojurebot1
23:34Scriptorwell, parsing and lexing
23:34amalloyjcromartie: yes it is?
23:34chrissbxjcromartie: that's Scheme let*; I'm missing something for Scheme let
23:34jcromartieOK maybe I misunderstood
23:35chrissbxScriptor: I'm writing it in Scheme, so I'm just using the parser of the Scheme system.
23:35amalloyeg, scheme code might look like (let ((x 1)) (let ((x 2) (y x)) y)) and expect y to be 1
23:35Scriptorah, got it
23:36jcromartiereally? I would not expect that
23:37jcromartieI've been away from Dr(Racket|Scheme) for a while
23:37amalloyjcromartie: that's because you're not writing scheme, apparently :P
23:37jcromartieyup
23:37jcromartienever more than a few toy programs
23:41amalloybtw chrissbx, did i get the let syntax right? i only used a non-clojure lisp for a couple weeks
23:42chrissbxyes, it's correct
23:44chrissbxBTW is there some pretty-printer in Clojure that takes a Clojure s-expr and formats it nicely? (not just reindentationm, but line wrapping as well, with good consideration of the special forms)
23:45chrissbx(or, takes a file with Clojure code all in one line, and reformats it)
23:45amalloy&(doc clojure.pprint/pprint)
23:45sexpbotjava.lang.Exception: Unable to resolve var: clojure.pprint/pprint in this context
23:46amalloyit takes some finagling, but it has some special-form support if you ask nicely, and pluggability for others you might care about
23:46chrissbxok