#clojure log - Mar 15 2012

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

1:41 archaic: I'm trying to implement the interface javax.swing.tree.TreeNode, the method children() expects the children returned as an Enumeration, how do I create the enum? (given I have the children as a seq)

1:49 amalloy: &(doc seq-enumeration)

1:49 lazybot: java.lang.RuntimeException: Unable to resolve var: seq-enumeration in this context

1:49 amalloy: ugh. it's around there somewhere, i think

1:49 (clojure.lang.SeqEnumeration. the-seq)

1:51 archaic: ^

1:51 archaic: Ahh thanks, (enumeration-seq) goes the other way - thats the one I needed

2:41 konr: Is there a more elegant way to create an instance using a list of args than (eval `(java.awt.Color. ~@[1 2 3]))?

2:49 pyr: konr: (defn constructor [vec-or-list] (clojure.lang.Reflector/invokeConstructor java.awt.Color (to-array vec-or-list))

2:50 konr: then (construtor [1 2 3])

2:50 konr: but that's not pretty either

2:50 aperiodic: heh, eval or interop

2:50 choose your poison

2:51 konr: thanks!

3:14 fliebel: Some of you have tweeted about smalltalk in the past, usually in relation to things it did right, but is it actually a nice language to program in?

3:21 scottj: fliebel: I liked it but wouldn't every choose it over clojure. I do think it's a very beautiful language but sometimes ugly features are nice too. The dev environment is also very impressive.

3:22 fliebel: scottj: I found a job in Smalltalk, which seems like a little crazy idea, which is why it interests me.

3:22 scottj: fliebel: JPM?

3:22 fliebel: scottj: JPM?

3:23 scottj: fliebel: guess not (jp morgan (chase))

3:23 they have a big deriviatives app written in smalltalk

3:24 fliebel: scottj: guess not. I had no idea about active Smalltalk use.

3:27 scottj: fliebel: programming in smalltalk now is kind of like the movie back to the future (and there's a famous smalltalk article with this name). it's definitely not a modern language and a ton of things you'd expect are missing, but you also realize the past wasn't that backwards and actually worked pretty well and had a lot of really good stuff that's lost from the modern world.

3:29 fliebel: scottj: Hm, I do think that we should learn from the past, but I'm not sure if a full time job is the right way to do that.

3:31 "Alan Kay has commented that despite the attention given to objects, messaging is the most important concept in Smalltalk"

3:32 echo-area: ``Ensure'' doesn't force the newest value, right?

3:37 raek: echo-area: if you mean that thread A reads X from ref R in the following scenario? then no. ref R contains Y, thread B enter transaction, thread A enter transaction, B sets R to X, A calls ensure

3:38 this article explains the STM really well: http://java.ociweb.com/mark/stm/article.html

3:38 echo-area: raek: You sent me that link some time ago ;-) I have read that. And I'm reading LockingTransaction.java.

3:39 I seem to doubt that ensure fixes write screw; I don't make it clear until now, and will discuss later here

3:40 raek: Thank you by the way :-D

3:50 fliebel: scottj: What kind of stuff doe Smalltalk not have? Except for regex literals and that nonsense.

4:12 Lajla: fliebel, a full hindly-milner static type inference

4:13 fliebel: Lajla: Like public static final int[]<a, b>?

4:14 Lajla: no

4:14 As in Haskell or OCaml

4:14 C++ most certainly does not have a hindly milner type system

4:14 Ehhh

4:14 Say you got some Haskell code

4:14 as in: square x = x * x

4:14 definition of the square function

4:14 fliebel: Lajla: That is what I mean, you have to type out al the types

4:14 Lajla: that is statically typed

4:14 Yeah, well, you don't in a hindly milner system because it can infer the types for you

4:16 fliebel: From what I read, Smalltalk is dynamically typed.

4:29 gtuckerkellogg: there's something i'm not getting about alter

4:30 I have a function, and if I run it (update-cache cc fresh-chr @cc-cache dirty-locs)) it works fine

4:32 but if I try to use it in an alter, with (dosync (alter cc-cache update-cache cc fresh-chr @cc-cache dirty-locs))

4:32 tsdh: Lajla: As a note on C++. In the brand-new C++11 spec, you can in many circumstances declare types as "auto", and the compiler will infer the correct type for you.

4:32 Lajla: tsdh, in what cases?

4:33 Like, how clear is it when you can do that

4:33 ?

4:33 tsdh: Lajla: http://en.wikipedia.org/wiki/C%2B%2B11#Type_inference

4:33 gtuckerkellogg: it throws an error Wrong number of args (5) passed to: core$update-cache

4:33 driving me nuts

4:34 tsdh: Lajla: If it doesn't compile, that's a case where it didn't work. :-)

4:34 Lajla: tsdh, don't hate me for not feeling save from that

4:34 But I'd admit that I got a passionate hatred for C++ which rivals the hatred republicans have for people who know how to turn a computer on.

4:36 tsdh: Lajla: I didn't use C++ seriously enough to have a strong positive or negative feeling about it. But at least I have to confess that they're making quite some progress. Who would have betted that C++ has lambdas before Java has some years ago?

4:36 mindbender1: gtuckerkellogg: i think you should read up a bit on alter works within a dosync.

4:37 alter will pass an extra argument to your fn

4:37 Lajla: tsdh, that is exactly my problem with C++

4:37 well, one of them

4:37 mindbender1: so your fn should be redefined to accept 5 args

4:37 Lajla: it keeps adding dfeature and feature and feature and feature to the point that its syntax isn even decidable at this point

4:37 gtuckerkellogg: ahhhh

4:38 Lajla: I mean, C++ syntax is just cluttered and unreadable at this point to account for that, not to mention that the language takes 3829382 hours to compile something simple and its errors messages are just ehrr..

4:38 Someone once managed to give me something which on his compiler generated 3 pages of error message from a simple typo

4:38 mindbender1: gtuckerkellogg: if you're within a repl .. (doc ?) helps

4:39 gtuckerkellogg: sorry about that

4:39 i read the (doc alter), but it's as if I didn't see that at all

4:42 tsdh: Lajla: Yes, the syntax is a bit "grown" over times. Ok, one could argue it was rather insane from the beginning.

4:43 Lajla: WRT error messages, the clang compiler does a pretty good job there.

4:47 emezeske: C++ errors can be problematic, but it's not like it's alone there

4:47 I have dealt with some ridiculous Clojure errors

4:48 You know the ones, deep in some library, happening in a lazy func somewhere

4:48 At least with C++, the crazy errors actually do contain the info you need to fix them (if you're willing to spend a bunch of time picking them apart to figure that out)

4:52 ivan___: emezeske: i doubt clojure has anything on jruby for crazy errors ;)

5:01 Raynes: Everybody digging the new editor on https://refheap.com?

5:01 I think it's pretty awesome, but I'm biased.

5:04 Lajla: Does clojure have a contracy system?

5:06 tsdh: Raynes: Wow, that even indents when writing directly in it.

5:08 Raynes: It has a problem with binding vectors (let, for, with-open) if you place each binding pair on a separate line. Then the second binding pair is indented to the value of the upper value.

5:10 Raynes: tsdh: Indeed. I'll file an issue on codemirror and see if I can tackle it myself. Thanks for pointing that out.

5:12 tsdh: Raynes: You're welcome.

6:10 lnostdal: http://dev.clojure.org/display/design/Improve+Binding "Yet that is often the expectation/desire" no it is not! :(

6:11 it causes weird leaks and assumptions .. agents execute "outside" of binding scope

6:13 Fossi: no emacs keybindings, no editor :>

7:28 lnostdal: http://dev.clojure.org/display/design/Improve+Binding?focusedCommentId=4653329#comment-4653329

7:28 how do you guys deal with this stuff?

7:32 clgv: lnostdal: that should work in clojure 1.3

7:33 lnostdal: oh. maybe not for an agent since it's threadpool might be running already. but if you spawn a new thread it should have the current binding

7:33 lnostdal: ok, i'm not sure when this change was made actually .. i'm on 1.4.x here now, so perhaps it's a 1.4.x thing; not a 1.3.x thing

7:34 hmm

7:34 huh, i'm saying new threads should _not_ have the "current" binding since they have no way of knowing what is "current" .. perhaps i misunderstood

7:34 clgv: I can imagine that there remains work to be done for agents

7:35 lnostdal: (the same goes for agents and futures too)

7:35 clgv: afair the thread has the current binding from the time where it was created (or even started?)

7:35 lnostdal: agents have bindings from the point of send or send-off

7:36 clgv: oh I misread the linked comment

7:36 lnostdal: ok

7:37 clgv: I think the 1.3 behavior is good. I assumed it doesnt know the binding

7:38 the question is when the binding should be inherited. once on the 'agent call or on every 'send call

7:39 the problem with resources in 'with-open that could occur with 'binding is the same as with lazy-se4qs

7:39 lnostdal: yes, it is

7:40 clgv: well this consistency is good as long the general problem is not solved ;)

7:40 lnostdal: and this stuff should even try to solve it automatically .. it leads to, hm, what's the term; false positives .. things that "seem to work" perhaps most of the time, but then doesn't sometimes

7:40 shouldn't even try*

7:41 clgv: probably things like with-open should be replaced in a pipes-and-filter style

7:45 lnostdal: perhaps, and perhaps that would work for stuff like with-db-connection and similar too

7:46 ..but i still think the "classic" with-* dynamic extent type resource handling should be "sane"

7:49 clgv: the problem in 'with-open is that you don't know when too close it if the sequence is lazy

7:49 *to

7:50 *the sequence that uses the file

7:53 lnostdal: that seems like an unrelated thing

7:54 when/if you're gonna use lazy stuff you won't be using with-* anyway

7:54 that seems like a totally different realm or way of doing things to me

7:55 clgv: hm ok. in clojrue 1.2 I had the problem with 'binding that it stop to work as soon as a thread was spawned that was pretty annoying

7:56 tomoj: but I always thought binding was for thread-locals

7:57 clgv: tomoj: it is

7:57 lnostdal: no, it's totally reasonable .. you have no way of knowing how long that binding will really last (point to a real / still open (i/o)) resource

7:57 ..when in a background thread

7:58 clgv: maybe it should treat resources special then. but for immutable values thats totally reasonable

7:58 lnostdal: however, there are some things which are reasonable to always forward/convey by-default though

7:58 yes, like *print-length* and stuff

8:00 i think i recall SBCL having a global variable with a list of default (and user added) bindings to forward/convey by default .. but the default/normal behavior was to not convey anything as it makes code in threads "magically work" in some cases where it'd been better to fail all the time so it got the users attention early

8:00 not convey anything new*

8:02 clgv: lnostdal: hmm, a configuration what to convey would be doable I guess

8:03 lnostdal: could be metadata

8:03 lnostdal: indeed

8:16 just patched my local clojure to not do this anymore and found 2-3 potential places where agents race with the extent of outer bindings .. i wouldn't have seen this otherwise; thing would just randomly have failed if e.g. the agent pool was somewhat busy .. perhaps i'm totally wrong about this or just nuts, but this seems to be the right thing to deal with this

8:17 right way*

8:17 clgv: clojure.lang.Var is the place to patch, right?

8:20 lnostdal: clgv, https://refheap.com/paste/1077

8:21 clgv: ah. I would have thought thats implemented in the java source ^^

8:22 well, easier that way ^^

9:55 mdeboard: I really need to add a mode hook for ignoring this join/quit spam

10:17 jorendorff: tewald: hey tim

10:52 pandeiro: tomoj: did you ever figure out why (io/copy (io/input-stream url) (io/output-stream filepath)) does an incomplete copy btw? still trying to fix my binary download fn from last night

10:54 simard: how do you get to evaluate functions typed by a user with clojail if eval is disabled from within the sandbox ? ie.: how does clojure-bot and tryclojure do it ?

10:56 TimMc: ,(let [evil (resolve (str 'eval))] (evil `(+ 1 2 3)))

10:56 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

10:56 TimMc: ,(let [evil (resolve (symbol "eval"))] (evil `(+ 1 2 3)))

10:56 clojurebot: 6

10:56 TimMc: simard: Well, in the case of clojurebot... :-P

10:57 simard: I believe the sandbox works by taking apart the submitted code and checking it against whitelists and blacklists.

10:58 simard: The dot form (. foo bar) is also replaced with something that does checks for forbidden methods, classes, and packages.

10:59 simard: so basically I would read a string into a form outside the sandbox, and submit that form to the sandbox.

11:03 (let [sb (sandbox secure-tester)] (sb (read-string "(System/exit 0)")))

11:03 great.

11:04 TimMc: simard: Yeah, but use a secure reader.

11:05 simard: ?

11:05 TimMc: I can break the snippet above in at least 2 ways.

11:05 clojail has a secure reader.

11:06 ,(read-string "`````````````````a")

11:06 clojurebot: Execution Timed Out

11:08 TimMc: &(take 7 (map (comp count flatten read-string) (iterate (partial str \`) "a")))

11:08 lazybot: ⇒ (0 2 8 41 221 1202 6548)

11:16 pandeiro: it's possible to nest with-opens right?

11:18 * wmealing waves

11:18 * TimMc particles

11:19 clgv: pandeiro: as far as I remember you can even open multiple resources in one with-open

11:20 pandeiro: clgv: yeah that i've done but i am opening a zip and then doseqing through the entries

11:20 clgv: pandeiro: should by no problem. with-open expands to try-finally-blocks

11:24 joegallo: clgv: yes, you can nest with-opens, pandeiro, yes you can have multiple resources in a single with-open -- correct on all counts

11:25 oh, i got confused there, that was all clgv explaining to panderio. please re-address my previous message accordingly. :)

11:25 pandeiro: joegallo: thanks, gotcha.

11:26 clgv: ;)

11:26 pandeiro: i really needed to update nakkaya's io primer with the stuff i'm learning... stuff's changed since 2010

11:35 wmealing: can anyone reccomend a good resource on setting up a clojure project with jenkins-ci ?

11:36 specifically a lein project

11:39 ah technomancy wrote one, thanks.

11:49 uvtc: pandeiro, didn't know about the takkaya site. Looked it up. Thanks.

11:50 pandeiro, gah. s/takkaya/nakkaya/

11:53 pandeiro: uvtc: yeah lotsa good stuff there

11:54 how does one get slime to recognize new libs added to the classpath since starting swank? or do i need to restart?

11:56 metajack: pandeiro: just jack-in again or use something like pomegranate (https://github.com/cemerick/pomegranate)

11:59 pandeiro: metajack: jacking in will clear my session variables?

12:00 pelleb: Hi guys. I'm trying to develop a ring auth framework based on OAuth 2. It's still early days, but I'd appreciate feedback on my clojure as I'm trying to learn idiomatic clojure while writing this. https://github.com/pelle/clauth

12:03 metajack: pandeiro: unfortunately yes.

12:32 jaley: has anyone had issues connecting to an nREPL from counterclockwise? i'm seeing a long pause followed by an IndexOutOfBounds

12:39 dabd: I have a lein project using clojure 1.2.0 but when when I run Mx-clojure-jack-in and eval *clojure-version* on the REPL it shows clojure 1.3.0. How is this happening?

12:44 joegallo: dabd: can you paste your project.clj? maybe one of your dependencies is pulling in clojure 1.3.0 or something like that.

12:44 if you ls lib, which version of clojure do you see there?

12:50 tmciver: dabd: I believe you have to M-x cd to a project directory first.

12:51 bhenry: will doseq wait to complete before moving on? or will it run in another thread?

12:52 raek: bhenry: it won't involve other threads

12:52 ,(macroexpand-1 '(doseq [x xs] (foo x)))

12:53 clojurebot: (clojure.core/loop [seq_33 (clojure.core/seq xs) chunk_34 nil count_35 ...] (if (clojure.core/< i_36 count_35) (clojure.core/let [x (.nth chunk_34 i_36)] (do (foo x)) (recur seq_33 chunk_34 count_35 (clojure.core/unchecked-inc i_36))) (clojure.core/when-let [seq_33 (clojure.core/seq seq_33)] (if (clojure.core/chunked-seq? seq_33) (clojure.core/let [c__3866__auto__ (clojure.core/chunk-first seq_33)...

12:53 dabd: joegallo: here are my dependencies from project.clj http://cljbin.com/paste/4f621e2ce4b06159e94b7f25

12:53 tmciver: I am running clojure-jack-in from the project.clj directory

12:53 raek: besides some optimizations, the doseq expands into loop and recur

12:55 mstump: how do you apply lazy-cat?

12:57 joegallo: dabd: so, yeah, one of your dependencies is pulling in clojure 1.3.0, and so you're getting that in lib

12:58 figure out which one, and add an exclude to it, and cross your fingers and hope it actually works with clojure 1.2

13:36 true_droid: what's the idiomatic way of converting a string into a number? or checking that a string contains a number (like Python's isdigit()?

13:36 (try (Integer/parseInt "…") …) is not applicable

13:38 dnolen: true_droid: what's wrong with Integer/parseInt?

13:38 true_droid: well, I'm solving this problem https://www.4clojure.com/problem/128

13:38 and it spits out this: "You tripped the alarm! catch is bad!"

13:40 TimMc: true_droid: "4clojure" and "idiomatic" often don't go well in the same sentence (because of the constrained environment)

13:41 true_droid: ok, pardon my request of an "idiomatic" way

13:41 pandeiro: true_droid: maybe you could use regex instead of try/catch to limit parseInt application?

13:43 TimMc: I'd probably solve this one with a slightly brute-force approach.

13:43 pandeiro: is vec a costly operation?

13:43 true_droid: I'll better use the range check to determine if the character is a number

13:43 like (if (>= (int rank-char) (int \2)) ...)

13:44 is relying on Java exceptions really idiomatic in Clojure?

13:44 technomancy: "(simple) Shen can be embedded straight into Clojure using the 神 and defprolog macros." o_O

13:44 true_droid: that would make the code slightly less portable if we take into account the fact that Clojure is also implemented on top of the CLR

13:45 plus there's also py-clojure currently in development

13:45 they would all have different exception classes

13:45 technomancy: true_droid: real-life programs are going to have a lot bigger portability concerns than exceptions

13:46 dnolen: pandeiro: not really

13:46 technomancy: pretty cool stuff

13:47 true_droid: technomancy: what do you mean? if I write a program in Python using only standard portable modules, it will work in JPython, PyPy etc.

13:48 if I write a program in JPython which uses JVM's features, it will not be portable of course

13:48 technomancy: dnolen: it would be interesting if it weren't for the license

13:48 true_droid: so the question is: isn't there a way to write portable Clojure code? (as in portable between VMs)

13:48 dnolen: true_droid: Clojure is probably one of the few programming languages to fully embrace heterogenous hosts. It rarely tries to solve problems which the host solves for you.

13:48 true_droid: non-hosty stuff yes, large app no

13:49 Chousuke_: Cross-host portability seems to be an explicit non-goal for Clojure.

13:50 I guess you could consider the various implementations a family of languages

13:50 true_droid: dnolen: so, writing in Clojure is like writing in Mac-Ruby then? your program will still be in Ruby, but it'll work only with Cocoa

13:51 dnolen: true_droid: for apps yes. But there *libraries* that can work everywhere w/ a little effort - core.match and core.logic come to mind ;)

13:51 pandeiro: dnolen: if i have collections i want to access by index, (vec coll index) would be the way to go then?

13:51 dnolen: ,(doc vec)

13:51 clojurebot: "([coll]); Creates a new vector containing the contents of coll."

13:51 pandeiro: oops i meant ((vec coll) index)

13:52 dnolen: pandeiro: as in the coll is not already random access? then you will have a conversion linear in the size of coll.

13:52 pandeiro: i am parsing messy csv data and i need to map some transformations and then be able to access by index

13:53 true_droid: dnolen: I see, thanks

13:53 pandeiro: so i parse with string/split which gives a vector, but then after mapping i have a list

13:54 dnolen: pandeiro: if you intend to do a lot of random access yes - yes convert to a vector

13:54 pandeiro: w/o knowing what you're doing hard to tell if ((vec coll) index) will actually be a bottleneck

13:55 pandeiro: dnolen: i assume the alternative would be to use loop somehow instead of map to transform a vector into another vector?

13:57 dnolen: pandeiro: no need to loop, map into vec is efficient because of laziness

14:00 true_droid: which music plays well with coding in Clojure?

14:00 emezeske: true_droid: Autechre?

14:01 TimMc: Fischerspooner

14:03 ieure: Is there some way to get at the Compojure URI template stuff from Ring middlware?

14:03 e.g. I have (GET "/user/:user-id" [] "stuff")

14:03 true_droid: thanks!

14:03 ieure: And I want to wrap that up with middleware that can look at :user-id.

14:06 duck1123: ieure, are you sure you want this as a middleware? (executed for all routes) or do you only want it when the path matches?

14:06 ieure: duck1123, Pretty sure I want it as middleware… And I can wrap only the routes that need the behavior, yeah?

14:06 duck1123: if it's the latter, :user-id should be available in the params

14:07 if you want to do url matching outside of compojure, look at clout

14:08 ieure: So this is what I have

14:08 https://gist.github.com/2045735

14:08 And in that, there is no :user-uuid in the request.

14:09 fdaoud: I wouldn't think there is a user-uuid because it's part of the url, not the request params

14:09 ieure

14:10 ieure: fdaoud, Yeah, I know.

14:10 duck1123: the route params don't get added till that path matches, so replace the [] with request, then print that request var, you should see it

14:10 ieure: Hmm.

14:11 Okay so next question is

14:12 Can I do something like (GET "/user/:user-uuid" [user-uuid request] ...) in my route?

14:12 Because the wrapper needs the full request.

14:12 But the function I'm calling needs the params

14:13 duck1123: clout/compojure does some funny stuff there for convienience, but {{:keys [user-uuid]} :params :as request} might work

14:14 mefesto: ieure: this should also work: (GET "/user/:user-uuid" [user-uuid :as req] ...)

14:15 dabd: joegallo: thx. I think I will try to migrate all my code 1.3.0.

14:15 fdaoud: ieure: try (GET "/user/:user-uuid" [user-uuid :as request] ...)

14:16 duck1123: converting to 1.3+ should be a lot easier now that the vast majority of dependencies are updated

14:16 fdaoud: that would be the whole request. you could also just get the params map with (GET "/user/:user-uuid" [user-uuid :as {p :params}] ...)

14:18 netrealm: What's the right way to run two functions in the "then" part of an if?

14:18 ieure: netrealm, (do …)

14:19 netrealm, Or (if-not error-case exprs*)

14:20 duck1123: actually, you would want when-not, otherwise you'd still have to use the do

14:20 netrealm: ieure, duck1123: thanks

14:24 dnolen: nice, ClojureScript get a mention in the ThoughtWorks Tech Radar http://www.thoughtworks.com/radar

14:24 gf3: hola, ibdknox, I'm sure you're sick of me by now, I have another suggestion/idea

14:25 ibdknox: I think noir-cljs might benefit from multiple builds a la lein-cljsbuild

14:25 ibdknox: for instance, I have my main app, which is heavy on the cljs and includes everything, but I also have a few landing pages that I'd like just a tiny bit of functionality on

14:26 ibdknox: and I would need them to be lean and snappy

14:35 bsteuber: hi everyone

14:35 Licenser: hi bsteuber

14:36 bsteuber: I am trying to read a clojure string while keeping track which form is on which line, for all forms

14:36 the clojure reader seems to do it for lists only

14:36 any idea on how I could achieve that?

14:37 Licenser: bsteuber look at this: https://github.com/Licenser/clj-highlight

14:37 I think I solved it in there

14:38 so it does not build datastructures from the string

14:38 bsteuber: cool

14:39 maybe I'll steal more than just the line numbers from this project ^^

14:40 Licenser: heh

14:40 what are you working on?

14:40 bsteuber: which ns contains the number stuff?

14:40 a clj IDE, of course :)

14:41 well not really, just now just some interactive testing tool

14:42 yoklov: man, after writing in clojure, having to writing in java again is just painful.

14:43 having to write*

14:43 Licenser: bsteuber the idea was to use a mangler for lines since you can 'remember' which line you're on by counting each newline token

14:43 bsteuber: Licenser: sorry I don't understand any of that code right now ^^

14:44 ieure: FAIL in (test-allowed?) (auth.clj:18) expected: nil actual: nil

14:44 wat

14:44 Licenser: ieure it is a slightly different nil, a bit more one-ish perhaps?

14:46 fdaoud: yoklov: +1

14:47 yoklov: I've been using functionaljava.org, it helps a little. but you still have a lot of java verbiage (that's never gonna go away.)

14:48 yoklov: fdaoud: the verbiage is one of the worst parts, and I'm not sure I could sell anyone on letting me use that library, haha.

14:49 though, some of those data structures would be really nice...

14:54 fdaoud: yoklov: yeah, data structures, map, filter, foreach, etc. with chaining helps write more readable code. you stash away logic in function objects.

15:04 yoklov: yeah, that would definitely be nice… But I'm using java for a school project and trying to convince my team to use that would probably just undermine my authority (i already shot down their plan to use a weird 3rd party gui library…).

15:05 fdaoud: yoklov: what was that library?

15:06 yoklov: hm, jgoodies i think? I remember it not looking particularly bad, just unnecessary for a chat application, which is what we're doing

15:06 AimHere: yoklov> Use Greenspan's 10th. Come back with a huge pile of code that just incidentally implements clojure, and say it's a domain specific language

15:06 fdaoud: oic

15:06 AimHere: Intended to make solving the problem easier

15:07 yoklov: AimHere: yeah, you're right, that's what i should be doing.

15:09 tomoj: pandeiro: no clue

15:10 pandeiro: actually

15:11 pandeiro: (let [os (io/output-stream "/tmp/doodle.jpg")] (io/copy (io/input-stream "http://www.google.com/logos/2012/yoshizawa12-hp.jpg") os) (.flush os))

15:11 seems to work

15:11 hmm

15:11 also (with-open [is (io/input-stream "http://www.google.com/logos/2012/yoshizawa12-hp.jpg") os (io/output-stream "/tmp/doodle.jpg")] (io/copy is os))

15:12 simard: amalloy: I was told to use clojail's "secure reader" if I need to evaluate something within the sandbox, is that (safe-read) ?

15:13 amalloy: yes

15:13 simard: so, (let [sb (sandbox secure-tester)] (sb (safe-read "(+ 1 2 3)")))

15:14 that and setting the java policy properly and I should be "safe", right ?

15:16 amalloy: yeah, that's about the safest clojail can make you

15:19 TimMc: simard: safe-read protects you against things like *read-eval* true

15:19 but also more tricksy things

15:22 pandeiro: tomoj: thanks yeah i solved it using (with-open...)

15:26 amalloy: TimMc: no other tricksy things

15:28 TimMc: amalloy: Wait, it doesn't guard against ```````?

15:28 amalloy: how could it? read throws an exception there

15:28 TimMc: try catch? timeouts?

15:29 * TimMc submits an angry pull request

15:29 amalloy: so? it catches the stackoverflowerror, let's imagine

15:29 TimMc: simard: Uh, so I guess I oversold safe-read.

15:29 amalloy: what's it gonna do? all it can do is throw it

15:30 TimMc: Magic, I don't know.

15:30 simard: what does ``````` do anyway ?

15:30 TimMc: I guess I'm thinking in Java terms, where you'd at least wrap the exception.

15:30 simard: Stack overflow / timeout.

15:30 &(take 7 (map (comp count flatten read-string) (iterate (partial str \`) "a")))

15:30 lazybot: ⇒ (0 2 8 41 221 1202 6548)

15:30 dnolen: fliebel: just wanted to say I'll get to your post - but it probably won't be until the weekend.

15:31 fliebel: dnolen: No problem, it's great that you want to think about the problem with me.

15:32 * fliebel got into 3 mind bending problems at the same time

15:32 dnolen: fliebel: definitely! it's a fun problem and less boring than Send More Money, N-Queens or Sudoku

15:33 fliebel: dnolen: Yea, I think it has real value. I posted something about it on an electronics forum, and apparently there are a dozen design apps, but only one abandoned generator.

15:35 dnolen: I also started to read the rest of the cKanren paper.

15:40 dnolen: Current thoughts: (divfd numerator denominator result remainder) lanes: ((1 2) (3 4)) wire-link = appendo? connectedo = (infd x y lane)

15:42 dnolen: fliebel: hmm, don't know where you're going with that yet, might be good for another post :)

15:43 fdaoud: TimMc: what kind of crackhead thing was that?! :-)

15:44 fliebel: dnolen: Me neither, they are vague conclusions based on the current limitations.

15:45 dnolen: Basically, we need to split and unify lanes.

15:45 We can only split if there is something to split, i.e. a list.

15:46 jamiei: Apologies if this is a dumb question, but is it possible to dynamically redefine a macro?

15:46 fliebel: So our domain is now 2D, but domains are only numbers, hence the divfd constraint, for translating a 1D domain onto a 2D space.

15:47 dnolen: fliebel: I don't follow, I need some serious hammock time with the problem.

15:47 fliebel: dnolen: Ok, I'll talk to you after the weekend.

15:48 dnolen: fliebel: Iooking forward to it!

15:52 amalloy: jamiei: i think it's an insufficiently-specified question :P

15:52 like, what do you imagine being able to do

15:55 jamiei: Ok, I have a macro that opens a connection. In order to test the code, I want to redefine it dynamically so I can not have to open the connection

15:55 Does that make more sense?

15:57 TimMc: Your macro opens a connection?

15:57 Oh, you mean it produces code that opens a connection.

15:58 jamiei: yes, absolutely right

15:58 my poor explanation

15:58 https://github.com/tavisrudd/redis-clojure/blob/master/src/redis/core.clj

15:59 TimMc: You can certainly redefine a macro -- I do that all the time in the repl.

16:00 jamiei: hmm

16:03 redefining it in the same way it was defined gives an illegal state exception, complaining over the conflict

16:05 * kakella says hello

16:06 * Licenser says welcome

16:10 raek: jamiei: are you trying to redefine it in the same namespace where it was originally defined?

16:11 you get a conflict if you try to define a var whose name is already associated with a var in another namespace

16:14 JulioBarros: Anyone here use noir? I've some how messed up my project and am getting blank response pages with no exceptions or messages. Any way to trace what is going on?

16:14 jamiei: raek: yes, ideally, I'm trying to replace the original so I don't need to open an actual connection for my tests

16:43 kakella: hello ... anybody up for a little configuration help? i am trying to get aquamacs working with slime+swank ... so far have a swank process running but no repl ...

16:43 clojure itself seems to be working fine ...

16:45 yoklov: what did you do to connect

16:45 lancepantz: kakella: i would strongly suggest against aquamacs

16:45 yoklov: ^^

16:45 y3di: oh wow i didn't know storm was half done in clojure

16:45 Luke: does pmap block until all the threads are done running?

16:45 kakella: i tried clojure-jack-in

16:46 lancepantz: kakella: `brew install emacs --cocoa`

16:46 yoklov: hm. okay. just making sure you weren't using one of the old ways to connect

16:46 lancepantz: much much better

16:46 kakella: any particular reason why not aquamacs?

16:46 yoklov: lancepantz: does that have fullscreen support now?

16:47 arohner: weavejester: I'm using clj-aws-s3, and when trying to save an object w/ get-object, I get Premature end of Content-Length delimited message body (expected: 566032010; received: 110962445). I don't think it's your fault, but have you seen that error?

16:47 kakella: is your clojure process already running with the swank server, or are you expecting clojure-jack-in to start it?

16:47 Luke: no

16:47 lancepantz: yoklov: native os x full screen, no

16:48 yoklov: that stinks

16:49 kakella: eh, at the very least, non-standard emacsen like that are more of a hassle than they're worth in the long run

16:49 kakella: arohner: i believe the process is already running ... but if there is a way i can check it then please tell me and i will try

16:49 arohner: kakella: aquamacs is slightly...weird compared to normal cocoa emacs. It used to be necessary several years ago when there was no cocoa emacs

16:49 kakella: ps ax | grep java

16:49 kakella: yes it is running

16:50 arohner: kakella: is swank? netstat -lant | grep 4005

16:50 kakella: you have two options: 1) start clojure yourself, your process is responsible for starting the swank server. Then connect via M-x slime-connect. 2) use clojure-jack-in, which starts the process+swank for you

16:50 kakella: looks like not for swank ...

16:52 arohner: kakella: if you want to go with 1), follow the directions under Embedding, https://github.com/technomancy/swank-clojure

16:53 tmciver: arohner: kakella: I don't believe 4005 is the default port for swank when started with clojure-jack-in. It seems to be a random port around 6x,xxx

16:55 kakella: I've had mixed results trying to connect to a running swank using slime-connect. In the past I've used the very ugly technique of attempting to quit emacs at which point it tells you that there are running processes and shows the swank port number.

16:55 kakella: i see in *swank* buffer a port number .. and if i netstat with that port number then i do get a result

16:56 arohner: kakella: try M-x slime-connect, and use that port number

16:56 kakella: that isn't supposed to be necessary w/ jack-in, but let's see if it works

16:58 kakella: arohner: well i got a message saying something like "take this REPL brother ..." ... but it did not open a new buffer ?

16:58 arohner: that's progress at least

16:59 do you have a buffer named something like *slime repl clojure*

16:59 kakella: no ... i have *slime-events* and *swank*

17:00 arohner: that's very strange

17:00 tmciver: kakella: yeah, it sounds like you've connected to swank but something is weird with emacs. you probably want to abandon aquamacs at this point.

17:01 kakella: a repl is supposed to open up when you get that message.

17:01 kakella: hmm ... ok so what's my best alternative to aquamacs?

17:02 arohner: kakella: http://emacsformacosx.com/ is good, or brew, macports

17:04 kakella: ok ... i'll try these alternatives and see if i get lucky :) thanks for your support Licenser, arohner, tmciver, yoklov, lancepantz

17:06 Licenser: kakella you are more then welcome

17:07 tmciver: who knew? emacs has a function 'list-processes' that can be used to find the swank port. That seems better than trying to kill emacs for the port info.

17:09 technomancy: tmciver: you can also see it in the *swank* buffer

17:09 tmciver: technomancy: I see. Cool.

17:14 rpt: Hi everyone, what is wrong with this:

17:14 (fn fcap [s] (str (filter Character/isUpperCase s)))

17:14 (noob question)

17:14 ,(fn fcap [s] (str (filter Character/isUpperCase s)))

17:14 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to find static field: isUpperCase in class java.lang.Character, compiling:(NO_SOURCE_PATH:0)>

17:15 Phlogistique: Hi

17:15 Arch Linux users among here?

17:15 yoklov: rpt: you can't use java methods as first class functions

17:15 tragically

17:15 Raynes: &(filter #(Character/isUpperCase \A) [\a \B \c])

17:15 lazybot: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox6997$eval11487$fn

17:15 Phlogistique: I installed the pacman clojure package

17:15 Raynes: &(filter #(Character/isUpperCase %) [\a \B \c])

17:15 lazybot: ⇒ (\B)

17:15 Phlogistique: In order to try Overtone

17:15 but when I type "lein"

17:16 I get an Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main

17:16 Raynes: rpt: You have to wrap it in a function, since that is a Java method and not a Clojure function.

17:16 rpt: yoklov: ah OK, thanks

17:16 Phlogistique: (I sourced /etc/profile.d/jdk.sh and /etc/profile.d/clojure.sh before)

17:17 just typing "clj" works fine

17:18 Here is the full backtrace http://sprunge.us/BXCB

17:20 yoklov: Phlogistique, you're using leiningen 2.0, have you tried the stable?

17:24 I don't know if that will make a difference, seems worth a shot though. I use arch and have gotten clojure working, but I don't recall how I did that (and i'm not at the right computer to check).

17:24 Phlogistique: yoklov: no I have not

17:24 I'll see that

17:26 now it takes more time downloading

17:28 yoklov: good luck, everything i've installed involving java in that distro has been a hassle

17:29 i really should just move to a saner linux

17:34 Phlogistique: here we go http://sprunge.us/TaHM

17:34 Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/core__init.class or leiningen/core.clj on classpath: (NO_SOURCE_FILE:0)

17:36 technomancy: Phlogistique: curl: (6) Could not resolve host: cloud.github.com; Name or service not known

17:36 Phlogistique: uh

17:36 sorry

17:39 kurtharriger: anyone know a good idiomatic way to trim or pad a vector to a desired size... take n works in the vector to large case is there anything idiomatic to pad a vector

17:41 technomancy: kurtharriger: (reduce conj my-vec (repeat n nil))

17:41 weavejester: arohner: No, I haven't seen that error before, sorry.

17:41 kurtharriger: cool thanks

17:41 Phlogistique: got lein working; thanks

17:42 technomancy: kurtharriger: can just use concat if you don't need to keep it as a vector

17:42 but there's no O(1) concat operation for vectors

17:43 kurtharriger: k, concat should work for me thanks

17:45 TimMc: kurtharriger: concat + cycle

17:45 or repeat

17:46 For padding I guess you don't want cycle in most cases.

17:49 kurtharriger: yeah just want to append 0 to the seq till it reaches desired length: (defn pad [v length padding] (concat v (repeat (- length (count v)) padding)))

17:50 TimMc: kurtharriger: (defn pad [v length padding] (take length (concat v (repeat padding))))

17:50 technomancy: nice

17:51 kurtharriger: that looks slightly cleaner and handles both cool

17:51 technomancy: s/v/coll/ for the argument name though

17:51 since there's no longer anything vector-specific about it

17:51 kurtharriger: yeah its more general then vectors

18:10 gf3: ibdknox: yt?

18:20 brehaut: "However, I'm not sure Clojure is going to impress Python developers for the reasons the author states. Python has metaprogramming and it has an immutable type (the tuple)"

18:20 O_o

18:20 yoklov: lol

18:21 clojure clearly cannot compete with the tuple

18:21 metajack: real immutable:

18:21 >>> f = ({}, [])

18:21 >>> f[0]["asdf"] = 1

18:21 >>> f

18:21 ({'asdf': 1}, [])

18:22 yoklov: well

18:22 brehaut: metajack: clojure's immutable datastructures are just as susceptible if you put a java object into them

18:22 yoklov: to be fair you're changing the dictionary there

18:22 and not the tuple

18:22 (i think, i don't know python)

18:22 metajack: there's hardly any point if it's not turtles all the way down.

18:22 yoklov: i agree with you there

18:22 metajack: you can't depend on tuples as values.

18:23 unless the value is the length of the tuple :)

18:23 yoklov: or you deal exclusively in tuples of tuples.

18:23 metajack: like church numbers ? :)

18:23 Frozenlock: In seesaw, is there a function similar to `input', but which can offer more than a single box? I would like to be able to let the user enter 2 (or more) different info at the same time.

18:24 yoklov: something like that :((),((),()))

18:24 emezeske: Bah, there's still plenty of reasons to use tuples

18:25 metajack: strings are immutable so you can build enough from there. but it would be pretty unpythonic and pretty tedious.

18:25 emezeske: And they *are* immutable -- they're just allowed to contain immutable references to things that are mutable

18:25 TimMc: metajack: "hardly any point"? Go use haskell, then!

18:25 metajack: (it's exactly how erlang works for the most part)

18:26 TimMc: You can do that in any language that allows any mutable objects.

18:28 Phlogistique: yeah, Python has metaprogramming, but it's pretty much against their culture, and even disregarding that it's Ruby-level metaprogramming - no true macros, need to remember the details and names of a lot of things

18:28 though "OMG, Clojure has metaprogramming thus it will knock out those pythonners" is a pretty ridiculous statement

18:29 emezeske: Comparing imperitive OO metaprogramming to AST metaprogramming is apples and oranges, really

18:29 Phlogistique: (Also, Haskell has (static) metaprogramming too!)

18:29 yoklov: well, the statement was that "python has metaprogramming so they won't need clojure"

18:30 Phlogistique: yoklov: yeah; it's a misleaded answer to a misleaded statement

18:30 yoklov: emezeske: i agree, you do very different things when doing, say ruby metaprogramming vs lisp macros

18:30 _ato: ...and people assume one is joking when one refers to FactoryFactoryFactories in Java. From the the standard library: (new XPathFactoryFinder(classloader)).newFactory().newXPath().compile(...) => XPathExpression

18:30 mdeboard: namedtuple is not an example of homoiconicity no matter what people tell you

18:31 Phlogistique: I will implement a Forth on CPython to knock out those pythonners with metaprogramming!

18:39 yoklov: … on that note does anybody want to see my implementation of unlambda in clojure?

18:40 https://github.com/thomcc/unlambda-clj

18:41 or, really https://github.com/thomcc/unlambda-clj/blob/master/src/unlambda_clj/core.clj

18:43 i finished it yesterday, and don't even feel bad about plugging it because writing in continuation passing style is a pain

18:54 * yoklov sighs

18:55 TimMc: Unlambda is pretty esoteric, dude.

18:55 yoklov: haha, yeah

18:56 it's really cool though, sort of blew my mind when i found out about it

18:56 and clojure made it a lot of fun to implement.

18:59 but i'll note that weird esoteric languages probably are crossing the "too out there" line

19:03 dnolen: yoklov: very cool, pretty code

19:03 yoklov: thank you!

19:04 dnolen: yoklov: having dug in to CLJS, I'm realizing Clojure is a pretty cool language for building interpreters and compilers.

19:06 yoklov: yeah, this made me realize that. being able to describe apply as a multimethod was… extremely awesome, to say the least

19:06 * brehaut hopes that typed clojure will be available to macros

19:07 yoklov: the biggest downside i noticed is no tail calls in clojure, which can make interpreters (such as this one) tougher

19:07 dnolen: brehaut: I had a chat w/ ambrosebs, sounds like when he's done he'll offer up the code as a Clojure contrib.

19:07 brehaut: dnolen: thats very exciting

19:08 TimMc: yoklov: Did you end up using trampoling?

19:08 yoklov: yeah

19:08 brehaut: return type polymorphism at compile time :D

19:09 yoklov: which worked perfectly, gotta say.

19:29 qbg: dnolen: I see LOGIC-30 was just upgraded to major priority. Are you taking a look at it currently?

19:32 dnolen: qbg: it's actually already available in a core.logic branch

19:32 qbg: Sweet!

19:32 dnolen: qbg: I haven't had a time to go over the patch in detail, I'm setting aside my weekend to do some intense Clojuring.

19:33 qbg: if your patch check out (which it looks like it will) I'll probably request that you replace the current system wholesale.

19:33 qbg: I plan to once it gets in :)

19:34 It was really fun to work on

19:34 dnolen: qbg: gotta run, but thanks very much for tackling this.

20:01 Frozenlock: I'm ready some compojure tutorials, and confused by the "public/file.css". Where am I supposed to create this public folder? In the project folder? In the source folder?

20:02 spoon16: project folder

20:07 Frozenlock: Thanks! However it still doesn't work. I must have messed somewhere else :(

20:20 weavejester: Frozenlock: If you're using route/resources, then the "public/file.css" should be included as a resource.

20:20 Frozenlock: By convention, the default Leiningen resources path is ./resources

20:20 Frozenlock: So the full path would be ./resources/public/file.css

20:24 clj_newb: Hi, had anyone had seen this error when installing vimclojure? Error: E117: Unknown function: vimclojure#AddCompletions

20:24 and loads like that

20:25 alexyk: how can I ask cheshire to parse unquiet keys?

20:27 clj_newb: it looks like it works thou

20:29 pbostrom: hey y'all, I want to mess around with a websocket server, is aleph a good starting point? I've also seen setups using webbit or jetty

20:41 archaic: When I run lein deps on a project that has native dependencies (in native/linux/x86_64) this folder is cleared/emptied - my current solution is just to re-copy it from a backup folder, what am I missing here?

21:15 brehaut: https://github.com/jduey/appraiser/blob/master/src/appraiser/forms.clj

21:16 it gets interesting around line 184

22:15 johnmn3: Hi

22:16 I'm working on a seesaw app. I'd like to embed a picture inside the resulting jar file

22:16 anyone know how to do that?

22:17 I figure I have to drop it in "resource" folder or something, but is there a tutorial on the web that speaks directly to this?

22:18 this may do it: http://stackoverflow.com/questions/8009829/resources-in-clojure-applications

22:18 qbg: Drop it in the resource folder and load it from the classpath

22:27 johnmn3: (.getFile (clojure.java.io/resource "picture.png"))

22:35 this is a little closer: (label :icon (icon (.getFile (clojure.java.io/resource "Airport-Blue.png"))))

22:35 still no worky

22:53 semperos: trying to use clojure.test.tap, (with-tap-output (run-tests))

22:53 when I try to evaluate that, I get an arity exception

22:53 error: clojure.lang.ArityException: Wrong number of args (0) passed to: test$testing-vars-str

22:54 but that function takes 0 args in the Clojure source...

22:55 or at least it used to...

23:46 johnmn3: (frame :title "title has icon" :icon (icon (clojure.java.io/resource "img.png") :content (blah))

23:46 does the trick

Logging service provided by n01se.net