#clojure log - Mar 30 2014

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

0:07 coventry: cddr``: Maybe something like (s/either (merge {:key1 (s/pred (partial = rval)), :key2 s/Any} other-requirements) (merge {:key1 (s/pred (partial not= rval))} other-requirements))

0:07 bjeanes: amalloy: is there a way to implement a protocol for java types such that they can be printed in a readable form?

0:08 like (URI. "the-url") ?

0:09 amalloy: bjeanes: i mean, you can add a print-method, but that's not actually readable: you have to run code to get '(URI. "x") to produce anything useful, whereas '[(x 1) (y 2)] is a value that the reader can produce

0:09 bjeanes: ah good point

0:09 well then... that is copy paste friendly :P

0:12 amalloy: like i said, print-method

0:19 gko: Can I do something like this: (def my-java-class String) then (new my-java-class "string") ?

0:19 Unable to resolve classname

0:20 amalloy: no

0:21 gko: ok thanks

1:36 mskoud: Anyone coming from Haskell? Any thoughts on the tradeoffs?

1:49 anildigi_: hi guys..

1:50 Joy of Clojure or Joy of Clojure second edition?

1:50 Which book should I read?

1:55 bob2: second

3:03 devn: bob2: both

3:03 anildigital: both

3:09 bob2: devn, why so?

3:16 chare: When is the clojure startup time going to get fixed?

3:18 Rosnec: chare: I was thinking about this today

3:18 the reason it takes so long is because of the bootstrap process

3:18 chare: oh good Rosnec you understand the details of the problem, so now we can unload and hound you until you fix it

3:18 Rosnec: if the compiler could somehow reduce the bootstrap rpocess to only what's necessary

3:19 it might be faster

3:19 idk if that's even possible though

3:19 it takes so long because it has to load clojure.core

3:19 chare: Rosnec does scheme and racket have slow startup time, if not WHY?

3:20 Rosnec: all of it, from what I understand

3:20 i dont know

3:20 I've only really used Common Lisp and Emacs Lisp outside of clojure

3:20 emacs lisp isn't really comparable

3:22 chare: its so messed up that clojure has the slowest startup time of the lisp dialects

3:22 that is just WRONG

3:22 Frozenlock: With, or without the jvm started?

3:22 chare: jvm isn't the problem

3:23 Rosnec: the reason clojure takes so long is because the language has to be built from a small number of functions, written in java

3:23 and that happens every time you start clojure

3:23 although, if you have a repl running already, I bet you could make it faster somehow

3:23 I have no idea how

3:26 anildigital: devn: why both books?

3:56 scottj: chare: https://github.com/galdolber/clojurefast people are working on it

4:58 mercwithamouth: has anyone here used liftweb and thought about/experimented with a view first pattern with compojure?

5:16 ptcek: I am following omtut-starter and got stuck on om/build-all. I don't get the following snippet and it's output: http://pastebin.com/ZQZnij31 What I am overlooking?

5:58 chare: what do you guys think of the book "Web Development with Clojure" and the library choices it makes?

6:00 scottj: chare: be more specific. it has been well received.

6:02 chare: scottj ok so I'm not going to find out that ring,compojure,hiccup,noir,liberator is like the old obsolete way of doing things

6:04 scottj: chare: ring, compojure and hiccup are timeless. the others, who knows.

6:05 chare: what does that mean

6:05 dark_element: chare, noir has been discontinued but other than that rest of the things are not obsolete.

6:05 chare: wtf do you mean noir has been discontinued?

6:05 the book uses noir and the book isn't that old!!!

6:05 dark_element: chare, read the first line. https://github.com/noir-clojure/noir

6:07 chare: oh I was calling lib-noir the name noir

6:07 didn't realize there was two separate existing things

6:07 dark_element: chare, all good things from noir moved to lib-noir which can be used with compojure.

6:11 bob2: let's freak out without reading any details!

6:12 dark_element: heh. when in doubt rtfm.

8:05 martinklepsch: hey, I'm trying to parse something patents from the USPTO which look something like this: https://gist.github.com/mklappstuhl/df82f4846c4d97639be3

8:07 parsing that w/ clojure.xml errs because clojure.xml apparently looks for the referenced dtd file — is there any way to not parse that dtd file?

9:30 paulswilliamsesq: hi all, has anyone any experience in stubbing webservice calls?

9:35 gfredericks: haha don't ##(update-in nil "some string" conj 2)

9:35 lazybot: ⇒ {\s {\o {\m {\e {\space {\s {\t {\r {\i {\n {\g (2)}}}}}}}}}}}

9:46 luxbock: when benchmarking between Java and Clojure programs, should I be compiling my Clojure source into a jar to get a fair comparison, or can I simply use the REPL?

9:51 ptcek: luxbock: compile, nREPL is optimized for fast startup and may be slower when running...

9:53 luxbock: alright

10:08 paulswilliamsesq: Hiya, any Midje users here?

10:13 gfredericks: b

10:13 un-b

10:14 I just got a POC debug repl working as nrepl-middleware

10:15 you can call (break!) anywhere in your code, and it stops there and hijacks the repl so that all future entries get eval'd in that lexical context

10:15 you can call (unbreak!) to continue

10:15 and they nest perfectly well

10:15 modulus: Hi there. I've been wondering hat the recommended way to write web applications is in clojure, since I think noir is sort of not really developed anymore.

10:15 is luminus the best way forward?

10:21 btbngr: why is def- ommitted in clojure.core? it seems rather unsymmetrical to have to use metadata there.

10:24 AeroNotix: yeah.... I always think this

10:24 perhaps it'll come one day

10:24 Bronsa: dont count on it

10:25 btbngr: I don't need to count on it, but. it's still silly.

10:25 gfredericks: a lot of folk deal with it by avoiding defn-

10:26 btbngr: but i like defn-. it's terse.

10:27 AeroNotix: gfredericks: why do you say that?

10:27 There's plenty of reason for private vars

10:28 gfredericks: no I mean using ^:private

10:28 btbngr: (def ^{:private true} foo 6)

10:28 (def- foo 6)

10:28 AeroNotix: gfredericks: oh you mean just use ^:private instead of defn-?

10:28 btbngr: why.. why would i want to type that? :)

10:28 gfredericks: (def ^:private foo 6)

10:28 AeroNotix: btbngr: fwiw you're making it sound worse

10:29 btbngr: :)

10:29 gfredericks: AeroNotix: yeah

10:29 btbngr: yes i am being a bit bit facetious. still.

10:30 AeroNotix: I

10:30 I'm +1 on def- and defn-

10:30 luxbock: hmm, so I used `lein uberjar` and then ran the resulting file with java -jar ./target/<file>, but for some reason the performance is much worse than when I run it from nREPL

10:31 I thought it would be faster

10:31 Bronsa: AeroNotix: adding def-/defmacro- & friends has been discussed a lot before, Rich and Stu's position is that it will never be added to core

10:31 AeroNotix: Bronsa: do you have a link to those discussions?

10:32 luxbock: in my -main I call (time (do-work n))

10:32 Bronsa: it's in the ml somewhere, let me search for it

10:32 AeroNotix: aight

10:32 btbngr: Bronsa: thanks. I'd be interested in the justification

10:32 luxbock: I know criterium would be better for more accurate benchmarking but the uberjar is running 10x slower than when I ran the function in nREPL

10:33 Bronsa: btbngr: if I remember correctly it was something among the lines of "we don't like private vars, so the more difficult we can make you make one, the better"

10:35 AeroNotix: Bronsa: but what's the justification for that?

10:35 btbngr: ... that sounds like a justification based on a rather shakey premis.

10:35 premise*

10:36 well, rather than have poor Bronsa play devils advocate, let's read the discussion :)

10:36 Bronsa: found it

10:36 gfredericks: luxbock: does the function return a lazy seq?

10:36 Bronsa: btbngr: AeroNotix https://groups.google.com/d/msg/clojure/gNhz72JSIaw/41KAjI6fXQ4J

10:36 gfredericks: or anything that contains one?

10:37 btbngr: Bronsa: thanks

10:37 AeroNotix: Bronsa: thanks, /me reads

10:37 Bronsa: AeroNotix: there's not much to read

10:37 I don't know if there are more threads where this has been discussed in more detail but that's the only one I could find

10:38 AeroNotix: Bronsa: quite the circular logic in there

10:39 btbngr: yeah, that's really quite crap logic. I'm quite happy deprecating defn- in core and reshuffling the library about a bit to move it OUT of core. *sigh*

10:40 AeroNotix: Oh well

10:40 it's not a huge pita

10:40 But yeah, this is one of the few rough edges of Clojure

10:41 Bronsa: https://groups.google.com/forum/#!msg/clojure/r_ym-h53f1E/y1S31QXNhcAJ this conversation looks more interesting and offers a few points

10:42 btbngr: "generally there is not as much reason to use a constant, for example". Unless, y'know. you're using a map as a function, etc... :/

10:43 Bronsa: AeroNotix: btbngr tldr: a reasonable reason (sorry :)) for having no def-, is that in core there are a number of def* macros, def- would only cover one of those

10:43 btbngr: yeah, the namespace explosion part is reasonable. deprecate defn-! :)

10:44 namespace? macro*

10:45 gfredericks: this is a good link to have on hand: http://dev.clojure.org/display/design/Why+Feature+X+Was+Declined

10:46 btbngr: More interesting is the "Compiler in Clojure" idea hammock. Is there a place I can find out more about how that is going?

10:47 Bronsa: btbngr: *ahem* I'm working on it

10:47 btbngr: I was just looking at 8700 lines of uncommented tree walking java dubbed the "Compiler" and became sad.

10:48 Bronsa: hi! I would like to contribute when I have a bit more time!

10:49 Bronsa: btbngr: every contribution is welcome, right now the "CinC" project is split between a number of libraries: tools.reader, tools.analyzer, tools.analyzer.jvm and tools.emitter.jvm

10:50 paulswilliamsesq: Hiya, I've been trying to combine test a function that uses clj-http to query a restful service with Midje. I've managed to successfully stub a service call using sonian/cartridge in :use-fixtures, but not as a background in Midje. No exception is generated, the function under test is executed but no cartridge is created. Any pointers in where to look?

10:50 Bronsa: you can find them in the clojure organization page on github

10:50 AeroNotix: btbngr: just remember the draconian agreement you need to sign before you commit to Clojure.

10:50 zachmassia: Is there an easy way to produce [[1 2] [3 4] [5 6]] from [[1 2] [3 4]] and [[5 6]]?

10:50 btbngr: Bronsa: excellent, thanks very much. Yes, I shall mail off a signature to rhicky personally :)

10:51 Bronsa: gfredericks: I don't think it's that good :/ all I read there is "We might add a feature if it proves good enough. We decide when it's good enough." but doesn't tell you what "good enough" means

10:52 gfredericks: Bronsa: well I can't imagine any sort of explicit rule

10:52 Bronsa: I'd argue that update-in or seqable? would be more useful than say, same? but yet same? has been added to core and update-in/seqable? still live in the mostly forgotten core.incubator

10:53 gfredericks: update-in?

10:53 Bronsa: durr

10:53 dissoc-in

10:54 gfredericks: And I assume s/same?/some?/

10:54 Bronsa: .. yeah

10:54 I haven't slept much. It shows

10:57 ptcek: zachmassia: try this ##(concat [[1 2] [3 4]] [[5 6]])

10:57 lazybot: ⇒ ([1 2] [3 4] [5 6])

10:57 zachmassia: ptcek: Awesome, thanks :)

10:59 gfredericks: Bronsa: I think I've come to the conclusion that any language design will be upsetting to at least 80% of its users

10:59 so I mostly just appreciate how powerful libs are and don't worry about what's in core as much except when it really can't be in a lib

11:00 luxbock: gfredericks:

11:00 nope

11:00 btbngr: gfredericks: hey. it's lisp. smoothing over the bumps is what it does.

11:00 Bronsa: gfredericks: we agree, I was just nit-picking. Overall clojure.core does a pretty good job

11:00 AeroNotix: gfredericks: that doesn't really apply to Lisps

11:01 gfredericks: we need some mechanism for measuring upsetness over IRC

11:01 AeroNotix: what doesn't apply?

11:01 AeroNotix: gfredericks: languages features upsetting people

11:01 technomancy: Bronsa: the rule is if it's needed for datomic it goes in

11:01 (how else do you explain uuid literals?)

11:01 gfredericks: technomancy: clojure.core is rhickey's utility library

11:01 AeroNotix: Which kind of is understandable, even if not quite perfect.

11:01 gfredericks: technomancy: I love the uuid literals

11:01 AeroNotix: gfredericks: lol

11:02 technomancy: gfredericks: I find them hilarious

11:02 btbngr: heh, yes, but he should really tidy up a bit. "where is it?" "it is all in the desk draw. ALL OF IT."

11:02 gfredericks: technomancy: I use them all the time at work

11:03 technomancy: gfredericks: you use them to name your libraries?

11:03 gfredericks: lein new #uuid "dce6bfa3-fa9b-4cfb-9579-05f2fa1a0026"

11:03 Bronsa: lol

11:04 technomancy: using your gherkin-based shell

11:04 gfredericks: most of these arguments boil down to "X is useful" "no it isn't" "I hate you"

11:06 btbngr: yes but CL throw everything in a single namespace... now look.

11:06 threw*

11:06 technomancy: well, uuid literals are pretty awesome compared to the only other reader literal that ships with clojure

11:06 btbngr: deprecate symbols!

11:07 technomancy: as reader literals go, they're better than average.

11:09 gfredericks: are uuids as strings prevalent enough in your system that you see significant memory savings by switching to uuid objects?

11:09 gfredericks: technomancy: the literal itself is fine, it's the default reader you're offended by

11:09 technomancy: do you like using dates as strings too?

11:09 technomancy: gfredericks: I'd take it over j.u.Date any day

11:09 gfredericks: compared to e.g. Joda

11:10 it's not just memory savings; I like the semantics of it

11:14 presumably also time savings when comparing

11:14 * gfredericks says without measuring anything

11:16 technomancy: but yeah, it's not that I find them silly on their own; just the way they are bundled with clojure and were used to introduce the concept of reader literals themselves is weird.

11:16 plus the fact that reader literals make the reader unsafe even with *read-eval* off makes me sad

11:26 gfredericks: unsafe in that reading edn can cause any code that you explicitly set up to run?

11:28 technomancy: no, I mean the actual reader is unsafe to run on user-provided code due to reader literals

11:29 hyPiRion: technomancy: well, only the reader literals you've provided, right?

11:29 technomancy: hyPiRion: no, an attacker could run arbitrary constructors

11:29 upwardindex: ,(ProcessBuilder. “ls”) ;; No matching ctor?

11:29 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ?ls? in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:30 hyPiRion: technomancy: with edn or the clojure reader?

11:30 technomancy: hyPiRion: with clojure.core/read

11:30 Bronsa: technomancy: that's because of the record literals, not because of tagged literals

11:30 hyPiRion: right, that's always funny

11:30 technomancy: Bronsa: oh right; sure. in my mind they're closely intertwined.

11:32 Bronsa: well record/deftype literals are at all effects read-time constructor invocators..

11:32 I wonder why they weren't limited to IRecord/IType constructors

11:32 technomancy: filed under "weird stuff I don't see the point of"

11:32 Bronsa: that would solve most issues

11:32 andyf_: G'day, folks. Good to see the channel topic version number updated.

11:34 Bronsa: Thanks for the heads up on tools.analyzer changes. By any chance, do you keep a list of Clojure compiler vs. t.a(.jvm) behavior differences somewhere (besides in your head)?

11:35 Bronsa: technomancy: yeah, I don't think I have ever used a record literal in code, but it's definitely nice that they print that way

11:35 yedi: does console.pprint or something exist for cljs

11:35 Bronsa: andyf_: no and I should really write one

11:36 andyf_: I guess TANAL tickets and email you sent to Mr. Baldridge would be a start.

11:36 Bronsa: that and some actual documentation :/

11:36 yedi: inspecting complex maps in cljs is a pain

11:36 andyf_: After Tim's talk, we should ask whether he is willing to write the docs :-)

11:37 I'll file a ticket adding a link to his talk to the README

11:37 Bronsa: good idea

11:39 technomancy: Bronsa: yeah, I just wish it used *read-eval* behind the scenes so there could be a way to keep it safe

11:39 gfredericks: technomancy: does this apply to clojure.edn?

11:39 Bronsa: technomancy: doesn't some *read-eval* value affects the record literal too?

11:40 I don't remember, I thought there was something for that

11:40 gfredericks: ,(defrecord Phil [])

11:40 clojurebot: sandbox.Phil

11:40 gfredericks: ,(Phil.)

11:40 clojurebot: #sandbox.Phil{}

11:40 gfredericks: ,(clojure.edn/read-string "#sandbox.Phil{}")

11:40 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>

11:40 Bronsa: ,#sandbox.Phil{}

11:40 clojurebot: #<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>

11:40 gfredericks: ,(require 'clojure.edn)

11:40 clojurebot: nil

11:40 Bronsa: there

11:40 gfredericks: ,(clojure.edn/read-string "#sandbox.Phil{}")

11:40 clojurebot: #<RuntimeException java.lang.RuntimeException: No reader function for tag sandbox.Phil>

11:41 Bronsa: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L617

11:41 gfredericks: I don't think edn has record syntax

11:42 gfredericks: so this really only applies to things like eval services that are probably already conscious of *read-eval*

11:54 oh speaking of inconsistencies with def macros -- apparently defonce doesn't even take a docstring

11:55 * gfredericks uses the metadata directly

11:56 bodie_: anyone have a recommendation for a /really great/ clojure book?

11:56 I have probably 15 years of experience programming, just never used a functional language

11:56 gfredericks: I've never heard a single bad thing said about the oreilly book

11:58 modulus: joy of clojure seems ok to me

11:59 btbngr: yeah it's not bad

12:01 gfredericks: I think this debug repl thing is going to actually work

12:01 wink: joy of clojure is good, but not sure it's a good first clojure book

12:01 ambrosebs: gfredericks: what's that?

12:02 gfredericks: ambrosebs: an nrepl-middleware I'm building; you call (break!) and it essentiall transfers your repl to the breakpoint

12:02 essentially

12:02 ambrosebs: sweet

12:03 gfredericks: it's turning out only moderately haxy, which is a lot less than I was expecting

12:03 already supports nesting

12:09 most of the haxiness is around having multiple nrepl sessions but letting the client pretend there's just one

12:10 since I don't think clients tend to support the idea of the server opening new repls for them

12:12 yedi: is there something like a print-let, that pretty prints all the binded vars when theyre made

12:14 gfredericks: don't think so

12:26 plaeremans: Hello there I would like to fork clojure.java.jdbc, do some modifications and produce a pull request, what is the best way to this wit a leiningen project ? I would like to test my modified version first ?

12:27 but can i modify that project and test it in another one, without recompilation

12:28 andyf_: plaeremans: If it is important to modify your local java.jdbc without recompiling it, and test it using a different Leiningen project, Leiningen has a 'checkouts' directory you can put your modified java.jdbc into

12:29 plaeremans: cool

12:29 andyf_: But modifying your local copy of java.jdbc and doing 'lein install' into your local Maven repo is pretty quick and easy, too, and then the other project you use to test it just needs to use the same version number as your locally-installed copy.

12:30 plaeremans: andyf, ok but I would love to remove the roundtrip time of that

12:30 than i don't have to restart my repo to test the modifications

12:30 ambrosebs: plaeremans: java.jdbc patches much go through Jira http://dev.clojure.org/jira/browse/JDBC

12:30 plaeremans: database connections to test it with is configured in anther project

12:31 ambrosebs: plaeremans: also you need a Clojure CA http://clojure.org/contributing

12:31 andyf_: http://stackoverflow.com/questions/7411326/clojure-lein-how-do-i-include-source-from-another-directory-in-my-project has some Q&A, and a link to the Leiningen docs on checkouts

12:31 gfredericks: https://github.com/fredericksgary/debug-repl

12:31 plaeremans: @andyf_ thanks, the ticket is already there : JDBC-64

12:31 But I fought I could implement it myself and submit a pull request

12:32 It will probably be rejected if I get to it

12:32 but when I do and there is feedback I'll learn something

12:32 andyf_: You can submit a patch with tests without having sent in a Clojure CA first, but the patch cannot be incorporated into java.jdbc without Clojure core folks having that on hand.

12:32 plaeremans: oh yes I forgot about that

12:32 andyf_: Pull requests will definitely be rejected.

12:33 Sean Corfield might be willing to give you feedback either way, depending upon his interest level and time available.

12:33 But it becomes more interesting for him if you have the CA submitted, and there is a chance your changes might make it in.

12:34 plaeremans: Why will pull requests be rejected isn't that the way to contribute code ?

12:34 I see on the clojure website that patches should be submitted via jira

12:35 andyf_: For Clojure itself, Rich Hickey prefers to review patches rather than pull requests. He says it is an easier workflow for him.

12:35 For other Clojure libraries, I think there is the desire to make the process consistent across them.

12:39 Rosnec: so I have a question about conventions

12:39 say there's a variable, foo, within the scope I'm working in

12:40 and I have some map that I want to destructure

12:40 and that map has a value :foo

12:40 I want to preserve both foo's

12:40 what's the conventional way of doing so?

12:40 I know I could do (let [old-foo foo, {:keys [foo]} m] ...)

12:41 is there a better way?

12:41 Bronsa: no other way if you want to use :keys

12:41 stcredzero: So, am I right in assuming that atoms that never experience thread contention are very low overhead?

12:42 Bronsa: Rosnec: what you could do however is (let [{foo' :foo :keys [..]} map] ..)

12:44 stcredzero: Also, is there any overhead that comes from having too many atoms in memory at once? (In order to assure no threads are contending for that atom)

12:45 Rosnec: Bronsa: so you're saying just use :keys for everything but :foo, and specify what to call :foo?

12:45 I guess that makes sense

12:45 Bronsa: yeah

12:46 Rosnec: is there a way I could use :keys and have a prefix added to everything?

12:46 Bronsa: no

12:46 Rosnec: ok

12:51 bbloom: stcredzero: atoms use simple compare and swap

12:52 stcredzero: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java

12:53 stcredzero: the overhead is essentially that of an AtomicReference, which has JIT support for producing machine primitives for atomic CAS

12:58 stcredzero: bbloom: cool. So that means there's little overhead, even in the face of thread contention.

12:58 bbloom: stcredzero: essentially, yes

13:01 Anderkent: stcredzero: the overhead when thread contention is high will probably come from repeatedly rerunning the update function, rather than the compare-and-set

13:12 shiranaihito: anyone know what this is about: "IllegalAccessError: Key does not exist" when i try to require "Key" like this: "[c2d.localization :refer [Key]]" ?

13:13 ("Key" is a record in "localization.clj")

13:13 bbloom: shiranaihito: records aren't vars

13:13 shiranaihito: for example:

13:14 ,(defrecord Point [x y])

13:14 shiranaihito: hm

13:14 clojurebot: sandbox.Point

13:14 bbloom: ,#'Point

13:14 clojurebot: #<CompilerException java.lang.RuntimeException: Expecting var, but Point is mapped to class sandbox.Point, compiling:(NO_SOURCE_PATH:0:0)>

13:14 bbloom: see?

13:14 shiranaihito: so how do i "import" it then? :P

13:14 bbloom: you can refer with the ->Foo factory method

13:14 ,(->Point 5 10)

13:14 clojurebot: #sandbox.Point{:x 5, :y 10}

13:15 bbloom: if you need the class object for instance? or something like that, you can use a fully qualified name (after requiring the namespace) or you can (i think) use :import like any other java class

13:15 shiranaihito: hmm

13:16 what does it mean to "refer with factory method"?

13:16 ambrosebs: Bronsa: do you do anything fancy working with 2 tools.analyzer repos simultaneously?

13:16 worth the pain?

13:16 bbloom: shiranaihito: (:require your.code :refer [->Foo])

13:16 (doc ->Point)

13:16 clojurebot: "([x y]); Positional factory function for class sandbox.Point."

13:16 shiranaihito: oh.. and then i can do (Foo. x) ?

13:17 bbloom: shiranaihito: #'->Foo is a var that simply calls new Foo with the same arguments

13:17 so just do (->Foo x)

13:17 shiranaihito: ok.. well, somehow i find (Foo. x) neater :P

13:18 so i guess i'll try importing it

13:18 bbloom: shiranaihito: they are different

13:18 consider:

13:18 ,(apply ->Point [5 10])

13:18 clojurebot: #sandbox.Point{:x 5, :y 10}

13:18 bbloom: ,(apply Point. [5 10]) # no good!

13:18 clojurebot: #<CompilerException java.lang.ClassNotFoundException: Point., compiling:(NO_SOURCE_PATH:0:0)>

13:18 shiranaihito: hmm

13:18 bbloom: ,(apply #(Point. %1 %2) [5 10]) # gotta do this

13:18 clojurebot: #sandbox.Point{:x 5, :y 10}

13:19 shiranaihito: aww.. i can't seem to import it

13:20 bbloom: (doc import)

13:20 clojurebot: "([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."

13:20 bbloom: ,(import 'sandbox.Point)

13:20 clojurebot: sandbox.Point

13:20 bbloom: seems to work

13:21 Bronsa: ambrosebs: I'm sorry I was having dinner

13:22 ambrosebs: :)

13:22 Bronsa: ambrosebs: do you mean for dev or when releasing?

13:23 ambrosebs: Bronsa: releasing mainly

13:23 Bronsa: with dev I assume you can connect them up in a repl somehow

13:24 Bronsa: ambrosebs: the only thing I need to do special is to bump the tools.analyzer dep from SNAPSHOT to whatever I just released before releasing tools.analyzer.jvm

13:24 and then moving it back to SNAPSHOT after the release

13:24 ambrosebs: ok

13:24 shiranaihito: bbloom: "ClassNotFoundException: c2d.localization.Key" .. :o

13:24 ohh.. that quote there

13:24 ambrosebs: I'm splitting up core.typed and I'm up to 6 repos. Need to figure out something easier than that.

13:24 bbloom: shiranaihito: did you (:require [c2d.localization]) first?

13:25 Bronsa: ambrosebs: eh 6 repos might be a pain

13:25 shiranaihito: bbloom: ah, nope.. damn, this is too complicated

13:26 bbloom: shiranaihito: the ns form is complicated/silly for sure, but the underlying mechanisms are quite simple. you're missing the key thing: when you define a type, a java class is prodcued and so is a factory function

13:26 shiranaihito: classes work just like any other class, the factory function works just like any other clojure var

13:26 shiranaihito: mmm

13:26 Bronsa: ambrosebs: also when dev I need to remember to mvn install locally tools.analyzer before e.g. reloading a repl so that it pulls the last snapshot

13:26 shiranaihito: now it's working but Cursive still shouts about importing "Key" :P

13:27 bbloom: shiranaihito: the one complication is that classes defined by clojure code are created at runtime, so they don't exist until the namespace they are in is loaded

13:27 shiranaihito: :/

13:27 bbloom: shiranaihito: remember, clojure's compiler is actually going to run your namespace file. so you can't possibly import a known java class until you load that file

13:27 shiranaihito: does that clear it up?

13:27 shiranaihito: yeah, that makes sense

13:28 thanks for the help! :)

13:28 bbloom: shiranaihito: also, you probably shouldn't have this problem :-P

13:28 ambrosebs: Bronsa: right. there's no way you could do that manually with 6 repos.

13:28 bbloom: shiranaihito: you should create a real public api

13:28 shiranaihito: how so? :P

13:28 bodie_: any preferred setups? I guess slime/emacs is out of style?

13:28 bbloom: shiranaihito: don't treat the class itself as part of your interface promise. instead provide a type predicate function and a smart factory function

13:28 shiranaihito: for example, going with the Point record example:

13:28 shiranaihito: bbloom: well, i'm just using "Key" as a marker for an error returned from a validation function etc

13:28 ambrosebs: Bronsa: I'm finding the separation very valuable, so I'll see how I go on my machine for a while

13:29 bodie_: i was looking at lein + lighttable but it looks like it uses an outdated version of Clojure.

13:29 shiranaihito: (and then checking instance? etc)

13:29 bbloom: ,(defn point? [x] (instance? Point x))

13:29 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Point in this context, compiling:(NO_SOURCE_PATH:0:0)>

13:29 bbloom: doh, timed out :-P

13:29 ,(defrecord Point [x y])

13:29 clojurebot: sandbox.Point

13:29 bbloom: ,(defn point? [x] (instance? Point x))

13:29 clojurebot: #'sandbox/point?

13:29 bbloom: ,(defn point [x y] (Point. x y)) ;TODO: add preconditions to ensure x and y are numbers

13:29 clojurebot: #'sandbox/point

13:30 shiranaihito: hmm

13:30 bbloom: shiranaihito: now later you can just do: (:require whatever :refer [point point?])

13:30 amalloy: bodie_: there's a good clojure plugin for most editors. emacs has a great one, if you already like emacs; i hear vim's is quite good as well; and eclipse, etc etc

13:30 shiranaihito: well, that makes sense but seems like extra typing

13:30 scottj: bodie_: what editor/IDE do you use for most other programming? use that

13:31 bbloom: shiranaihito: you should be defining so few new types that this extra typing is a marginally small cost in the general case

13:31 Bronsa: ambrosebs: maybe there's some plugin for lein to manage multiple repos

13:31 shiranaihito: bbloom: mmm.. luckily i haven't gone crazy with Records yet :p

13:32 amalloy: shiranaihito: bbloom's suggestion gives you more flexibility, too - you don't have to stick with the Point record if you decide you need some other data associated with them

13:32 shiranaihito: hm

13:32 amalloy: like, maybe a point holds, as well as its x/y coordinates, a cache of distances to other points. that's easy to add onto the point function without changing its args

13:32 but you'd have to add a new arg to the Point constructor to hold it

13:32 shiranaihito: you mean the "factory method" allows for flexibility if/when needed?

13:33 ambrosebs: Bronsa: true. unsure if I want to maintain 6x pom.xml and 6x project.clj's.

13:33 shiranaihito: yep

13:34 well, fiddling with the imports and stuff is so annoying that maybe i'll just write those "extra" functions.. although it doesn't feel very "feng shui" for now :P

13:34 ambrosebs: I'll play it by ear

13:42 elfenlaid: ehm, kind of silly question :) who knows where source of "`" function can be found or how it called properly? under properly I mean, for example, ' is called quote :)

13:43 ambrosebs: elfenlaid: it's called syntax-quote

13:43 elfenlaid: grep for that in the Java sources

13:44 elfenlaid: wow, thanks

13:44 ambrosebs: elfenlaid: good luck :)

13:49 doky: hello is here anybody how understands http-kit ?

13:50 i want to know to to redirect a request ? it said that follows Ring spec but it can not redirect ... ? does anybody know how to do that?

13:53 rberthel: there is a redirect in ring.util.response/redirect

13:56 doky: yes i added it to project, but it didn't redirects

14:02 Bronsa: elfenlaid: you can read https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L521 for an implementation from scratch that mimicks the one used by clojure itself or https://github.com/brandonbloom/backtick/blob/master/src/backtick.clj for an alternative implementation

14:03 bodie_: amalloy, scottj -- i'm a vimmer but interested in getting into emacs live programming, kinda the lighttable setup via emacs if possible :)

14:03 I saw some cool stuff with emacs tree manipulation that took me by surprise

14:05 elfenlaid: Bronsa, that's interesting, thanks :)

14:08 bbloom: elfenlaid: the backtick readme also links to my blog which might have some insight in to why/how

14:09 elfenlaid: bbloom, heh, clojure community is awesome!

14:11 whodidthis: doky: return {:status 302 :headers {"Location" "/coolplace"}} in handler

14:13 doky: thanks it worked also with ring redirect, i did silly mistake but thanks for response :)

14:39 stcredzero: Anderkent: are you saying that function call overhead is much larger than atom cmp-set overhead?

14:41 bbloom: stcredzero: he's saying that the function you give to swap! should do as little work as possible, but no less than necessary

14:42 stcredzero: bbloom: In other words: "optimize" -- or to be more specific, the duration of the swap function should be short as possible if there may be thread contention

14:44 bodie_: emacs/clojure newb here, any pointers? I'm looking at CIDER

14:44 cool articles the community loves that I'm unaware of... etc

14:44 bbloom: stcredzero: based on past discussions and your current line of questioning, i'll be very explicit: do NOT optimize here. you'd be wasting your time in a big way

14:45 stcredzero: if you have a very expensive operation, don't use swap! on a shared atom, since cheap operations may beat you and force you to restart the operation

14:46 stcredzero: bbloom: so expensive operations are ok on a non-shared atom (or while an atom is only being molested by a single thread)

14:47 bbloom: stcredzero: i'd probably have chosen a nicer way to say that, but yes.

14:47 stcredzero: the principle is simple: get-value, perform function, compare-and-set. if value changed during those steps, compare fails, retry

14:49 obviously if "perform function" takes too long, other operations can consistently prevent your comparison from passing, forcing you to retry indefinitely

14:49 stcredzero: bbloom: so changing around one's architecture to ensure that predominantly only single threads are going after one atom tends to be good

14:49 bbloom: stcredzero: absolutely not.

14:50 stcredzero: bbloom: you seem to be contradicting yourself

14:50 bbloom: stcredzero: no, no i am not

14:50 stcredzero: i've been very clear in my guidance each time we've spoke

14:50 you are prematurely optimizing without measuring in a big way

14:50 i'm explaining the principles to you so that you know what to look for

14:50 ... when you measure

14:51 stcredzero: did you talk to me previously under a different name?

14:51 bbloom: atoms are designed to be used by many threads simultaneously

14:51 stcredzero: most recently we discussed pmap

14:52 you can have dozens of threads hammering on an atom and it will outperform any lock-based solution with ease

14:52 but, as the name "atom" suggests, it's designed for atomic operations

14:52 and atomic is a carefully chosen word, meaning both "small" and "indivisible"

14:52 stcredzero: bbloom: you have no idea what I am and what I'm not measuring

14:53 bbloom: stcredzero: if you get defensive again, i'll stop offering my help

14:53 stcredzero: bbloom: keep in mind that I'm trying to devise a new kind of architecture and I'm not necessarily trying to use these devices for their usual purpose

14:54 bbloom: stcredzero: if you're trying to abuse the constructs, then you're probably better off using the java.util.concurrent bits that underly them

14:54 stcredzero: How about this: your help is very valuable when you talk about the performance of the components. But beyond that, you tend to jump to conclusions and get preachy.

14:54 bbloom: ok, i'll shut up then

14:55 stcredzero: bbloom: in other words: please continue to provide insight about the components, but stop >speculating< about what it is I'm doing.

14:56 bbloom: you have been wrong almost every time

14:58 bbloom: stcredzero: i'm not saying that this is true about you in person, but you should be aware that the way you write here in irc gives off a very hostile tone. at the conference, somebody said "so how about that pmap thing in irc" and there were several respected folks who expressed disbelief in the way you conducted yourself. if that was unintentional, you should be aware of it and adjust accordingly

14:59 bodie_: freenode #clojure is a great place to have personal arguments

14:59 bbloom: bodie_: my apologies. stcredzero: happy to discuss privately if you wish to understand/correct. i'll refrain from discussing publicly further

15:00 stcredzero: about the pmap thing: we were taling past each other because you kept saying things that were untrue about what I am designing, because you are speculating about what I am doing. I find that people contradicting me like that comes off as condescending

15:01 bodie_: not trying to be an ass, just saying. hehe. :)

15:01 bbloom: bodie_: no no, you're right

15:02 bodie_: thank you

15:02 bodie_: I applaud your mature response... I probably would've said something like "NO U!"

15:02 konr: How can I find out which Protocols an object implements?

15:03 bbloom: bodie_: mature+blunt is a fine line :-P

15:03 amalloy: konr: not possible in general

15:03 the information about protocol implementation is stored on the protocol itself, so you'd have to iterate over all existing protocols

15:08 tomjack: I was going to ask "how do I write clojure.core.async/map" in more complicated terms, then I found it :)

15:09 `szx: has anyone had a chance to play around with https://github.com/galdolber/clojure-objc and/or can tell me how viable it is?

15:09 just thought i would ask before diving in

15:24 munderwo: Hi all. Im playing around with Aleph, and am running into some issues. This is what I have so far https://www.refheap.com/69070 . Now when I curl at the server after running "lein ring server-headless" I get 'clojure.lang.ArityException: Wrong number of args (0) passed to: core$handler' .

15:25 If I run (start-http-server handler {:port 8080}) from the repl it works. But obviously something im doing is not passing the right parameters into the handler. Any ideas?

15:30 amalloy: munderwo: line 14 is calling (handler) with zero arguments

15:30 you just want handler, not (handler)

15:31 munderwo: amalloy: ahhh!

15:31 facepalm!

15:39 hmmm. I'd like to use lein-ring . But it seems there is a mismatch between what aleph provides with its start-http-server and what lein-ring wants.

15:40 Has anybody uses these two together?

15:40 this is what I have in my project.clj. https://www.refheap.com/69075

15:41 when I try use 'lein ring server-headless' and do a request I get 'clojure.lang.ArityException: Wrong number of args (1) passed to: server$start-server$fn'

16:15 TravisD: Does anyone know if incanter has a multiple-argument version of $join? Or do I need to write one myself using reduce?

17:27 kuppu: Hi #clojure

17:55 Rosnec: how is it possible that I can run my program without errors using "lein run", but if I try to compile it to a jar, I get a NullPointerException when trying to compile one of my files?

17:56 it's happening at the very first line of one of my files, and it's a file that was working well when I just did "lein run"

18:06 yotsov: Rosnec: adding gen-class to the ns declaration maybe?

18:07 Rosnec: the ns doesn't have :gen-class

18:07 I should have mentioned that, yotsov

18:07 my core.clj has :gen-class, but this is a different file

18:08 ohhh

18:08 I think I might have found it

18:08 or maybe not...

18:08 no, that wasn't it

18:09 I found an import to something I removed

18:09 but that was in a different file anyway

18:11 yotsov: Rosnec: something to do with a BOM on windows maybe? first-line issue brings this association...

18:12 Rosnec: nope, running linux

18:23 hiredman: Rosnec: check all your calls to io/resource, one of them is returning nil

18:23 (or paste bin the whole stacktrace for the npe)

18:26 Rosnec: here's my stacktrace

18:26 http://pastebin.com/8knb7y0L

18:26 i dont know how to show past the "and 49 more"

18:27 I mean "... 49 more"

18:27 jeremyheiler: Rosnec: stack traces are backwards, the 49 more are the lines above

18:27 Rosnec: oh

18:28 so that actually is the whole stack trace?

18:28 I always thought it just got clipped of at a point

18:29 hiredman: Rosnec: put (:refer-clojure :exclude [send]) in your ns form

18:29 Rosnec: oh

18:29 is that really it?

18:29 I thought it was just a warning

18:30 I knew there was something like that I needed to get rid of the warning

18:30 aand it compiles now

18:30 lol

18:30 well I won't make that mistake again

18:30 hiredman: I am not sure, there are some bugs ragarding overriding the vars from clojure.core and aot compiling

18:31 jeremyheiler: yeah

18:31 oops

18:31 (wrong room)

18:32 kuppu: Would anyone be able to help me understand the difference between a vector and a list?

18:32 "lists are used for code and vectors for data". What's that supposed to mean?

18:32 brehaut: $seen dnolen

18:32 lazybot: dnolen was last seen quitting 6 weeks and 6 days ago.

18:32 Rosnec: you write your source code with lists

18:33 (+ 2 2) is a list with the elements + 2 and 2

18:33 if you want a list of data instead, use vectors

18:33 kuppu: Hmmm

18:33 Rosnec: say you want to store a bunch of (x, y) pairs

18:33 kuppu: Yeah

18:34 Rosnec: you should have them in vectors [x y]

18:34 or some other kind of seq

18:34 hiredman: http://dev.clojure.org/jira/browse/CLJ-1392

18:34 Rosnec: but if you're going to literally write out the elements

18:34 you should do it with a vector

18:34 kuppu: Alright, let me digest this for a bit haha

18:34 Rosnec: so don't do this: '(x y)

18:34 do this: [x y]

18:35 Bronsa: Rosnec: more specifically http://dev.clojure.org/jira/browse/CLJ-1241

18:35 Rosnec: hiredman, Bronsa: thanks

18:36 good to know it's a bug and not me being stupid

18:36 hiredman: well, aot compilation is full of that kind of stuff, best to not do it

18:36 kuppu: Rosnec: thanks for the help :)

18:37 Bronsa: .. or we could juxt fix it

18:37 Rosnec: yeah, lol

18:37 unless you're saying aot is just not ready for use yet

18:38 hiredman: Bronsa: go a head, given that aot is rarely (if ever) required I've got another things to do :)

18:39 Rosnec: it makes launching your program faster, once it's compiled

18:39 hiredman: even if that issue is fixed, aot compilation still generates classes files for transitive namespaces, which can break things, and once you fix that, the aot'ed class files still won't be abi compat with different version of clojure

18:40 etc etc

18:40 Rosnec: I'm mainly just doing it because I'm writing a client/server program, and if I don't AOT compile on one machine, I have to compile on both machines every time I run it

18:41 hiredman: I am not sure the current aot should be "fixed" maybe it should be redesigned and replaced

18:41 Rosnec: no you don't

18:41 Rosnec: it's quicker to make a jar and scp it than to push to git, pull on the server, and use "lein run" on both sides

18:41 hiredman: ugh

18:41 Rosnec: is there an easier way?

18:41 hiredman: don't use git for deployments

18:41 don't stick jars in git

18:41 Rosnec: I'm not sticking jars in git

18:41 hiredman: don't use lein run to run your servers

18:42 Rosnec: then what do I use?

18:42 jeremyheiler: Rosnec: package your clojure code in a jar (it doesn't need to be aot compiled) and run it with java -jar

18:42 hiredman: on your build machine use lein uberjar (which doesn't require aot compilation) then use java -jar the-uber-jar.jar clojure.main -m your.main.namespace to run it

18:42 Rosnec: I'm using lein uberjar

18:43 actually, I think i set the :aot option in my package.clj without really thinking about it

18:43 hiredman: -m will look for a -main method, like gen-class uses, but -m doesn't require aot compilation

18:43 Rosnec: no wait, I didn't set the :aot option at all

18:44 then why is lein uberjar doing aot?

18:44 hiredman: Rosnec: :main (in some versions of lein) implies :aot

18:44 Rosnec: oh

18:44 I think I read that before

18:44 hiredman: because :main sets the main class in the jars manifest, and for their to be a class there needs to be aot

18:45 Rosnec: ah

18:46 hiredman: there

18:46 danielszmulewicz: seancorfield: ping

18:47 Bronsa: hiredman: meh. if there's a bug we should fix it regardless.

18:48 technomancy: or just fix your code so you don't get that warning

18:48 Bronsa: also that bug is not really specific to AOT, try to eval (let [] (def inc #(+ 1 %))) in your repl

18:49 technomancy: AOT causes all kinds of problems in development, but it's perfectly appropriate to do during deployment as long as you don't shadow core vars like it tells you not to do

18:49 and as long as you start afresh every time

18:49 Bronsa: the only real bugs that I encountered that are AOT specific are ClassLoader related

18:50 hiredman: Bronsa: there are bugs and there are hazzards

18:52 Bronsa: the transitive compilation is a real problem if you have an aot'ed app that you then want to use as a library in another app, but that other app needs to specify a different version of some library the first depends on

18:53 which if the library is backwards compatible should be fine, but because of transitive aot compilation, you'll have two versions of the library on the classpath

18:54 these are all problems I've run into at work in the past two weeks

19:12 bodie_: i noticed the lein plugin for lighttable is using an outdated version of clojure

19:12 I was going to try and set up everything around lighttable but now I'm not so sure

19:16 brehaut: i may well be wrong, but i dont think the version of clojure lein uses impacts the version you use in your own program

19:16 michaniskin: bodie_: https://groups.google.com/forum/#!topic/light-table-discussion/FnM4lwYA2eI

19:17 sorry disregard :/

19:20 bob2: lein by default invokes a new jvm for your app

19:38 munderwo: Hi all. So I want to turn this vector [0 1 2 3 4] into {:0 0 :1 0 :2 0 :3 0 :4 0}

19:38 so far I have (map #(assoc (keyword %1) 0 temp) [0 1 2 3 4])

19:38 which gives me ({0 {}} {0 {}} {0 {}} {0 {}} {0 {}})

19:40 bjeanes: munderwo: you might want to use (reduce) with an initial empty {}

19:41 bbloom: ,(into {} (map (juxt keyword identity) [0 1 2 3 4]))

19:41 clojurebot: {nil 4}

19:42 bjeanes: ,(reduce #(assoc (keyword %2) 0 %1) {} [0 1 2 3 4])

19:42 clojurebot: {0 {0 {0 {0 {0 {}}}}}}

19:42 bbloom: hm

19:42 bjeanes: er.. lol nope

19:43 bbloom: ,(into {} (map (juxt (comp keyword str) identity) [0 1 2 3 4]))

19:43 clojurebot: {:0 0, :1 1, :2 2, :3 3, :4 4}

19:43 bjeanes: except munderwo wants the value to always be 0

19:43 so not identity

19:43 bbloom: bjeanes: oh, i misread. *shrug* juxt constantly is getting ugly :-P

19:44 ,(into {} (map (juxt (comp keyword str) (constantly 0)) [0 1 2 3 4]))

19:44 clojurebot: {:0 0, :1 0, :2 0, :3 0, :4 0}

19:44 bbloom: but better:

19:44 amalloy: munderwo: why do you want (keyword "0") as your key? just 0, the number, would be the usual thing

19:44 bbloom: ,(into {} (for [x [0 1 2 3 4]] [(-> % str keyword) 0]))

19:44 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>

19:44 bbloom: ,(into {} (for [x [0 1 2 3 4]] [#(-> % str keyword) 0]))

19:44 clojurebot: {#<sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267 sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267@8ed62> 0, #<sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267 sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267@18f143> 0, #<sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267 sandbox$eval259$iter__260__264$fn__265$fn__266$fn__267@18790d7> 0, #<sandbox$eval259$iter__260__2...

19:45 bjeanes: yikes

19:45 bbloom: ok i'll stop coding in irc, i'm bad at it :-P

19:45 munderwo: umm.. It might be through ignorance? I want it to be a counting mechanism for a list of things that I have. So I can inc :0 when the zeroth element gets used etc.

19:45 bjeanes: hahah clojurebot accepts PMs I just realized

19:45 bbloom: ,(into {} (for [x [0 1 2 3 4]] [(-> x str keyword) 0]))

19:45 clojurebot: {:0 0, :1 0, :2 0, :3 0, :4 0}

19:45 bbloom: there we go :-P i suck.

19:45 bjeanes: I'm too lazy to use a repo so apparently clojurebot just became my private repl

19:45 s/repo/repl

19:45 bbloom: munderwo: you can simply use numbers as keys... this isn't javascript! :-)

19:46 munderwo: ahh ok. didnt realise that :)

19:46 bbloom: munderwo: also, if your keys are a dense indexes, you can just use a vector as a map directly

19:46 bjeanes: but at that point why are you using maps?

19:46 bbloom: ,(update-in [0 0 0 0 0] [2] inc)

19:46 clojurebot: [0 0 1 0 0]

19:46 bjeanes: yes that

19:46 munderwo: Yeah. I just like maps I guess :)

19:46 cool. well i've learnt two things today :)

20:20 chare: Do you guys use lib-noir for validation even though using the following functions result in code based on side effects not pure functions [noir.validation :refer [rule errors? has-value? on-error]]

21:30 DomKM: ,(str (char 0))

21:30 clojurebot: "

21:30 DomKM: ,(= "" (str (char 0)))

21:30 clojurebot: false

21:30 DomKM: why?

21:30 clojurebot: http://clojure.org/rationale

21:31 DomKM: heh, I didn't realize clojurebot responded to "why?"

21:31 jeremyheiler: ,(count (str (char 0)))

21:31 clojurebot: 1

21:31 nightfly: why not?

21:32 DomKM: Why is "" not email to (str (char 0))?

21:32 gah, I'm tired. Not *equal* to

21:32 jeremyheiler: because empty is different than something that isn't

21:32 the char 0 is not a displayable character

21:32 so it appears empty in a repl

21:33 DomKM: jeremyheiler: ah, got it. Thanks

21:34 AmandaC: Java Strings can contain embedded nulls, so I assume that Clojure ones can too. so (str (char 0)) is presumably making a string of length 1 with a null as the sole char

21:36 DomKM: How can I filter invalid chars ( (char 0), (char 1), etc. ) from valid chars ( (char 42) )?

21:38 kuppu_: Whoa, there's a clojure bot that runs clojure code?

21:38 jeremyheiler: DomKM: You can filter based on char ranges, whcih you can identify by looking at an ascii chart. Though, perhaps you could explain why you want to do that in the first place?

21:40 DomKM: jeremyheiler: Thanks, that's what I'm doing now. I'm using LevelDB and need to be able to pick a larger char to set an end point for an iterator.

21:41 jeremyheiler: what do you mean by larger? higher integer value? also, compared to what?

21:42 DomKM: jeremyheiler: Yes, higher integer value, I believe. LevelDB sorts keys in lexigraphical order

21:45 amalloy: DomKM: in that context i don't see why you would care about the difference between (char 1) and (char 42). both work fine as a byte value that you can use as the endpoint for an iterator

21:46 DomKM: amalloy: I suppose that's true. Hadn't considered that, thanks.

21:55 startling: can I use a type from defrecord in Java?

21:58 brehaut: startling: i think yes but maybe requires some AOT shenanigans?

22:29 amalloy: startling: yes, but as brehaut says you have to AOT your stuff. plus, records aren't a ton of fun to work with from java anyway. consider whether you can instead produce an interface containing the methods that java folks would care about, and then provide a way to get instances of that interface

22:30 startling: amalloy, that's possible.

22:30 gfredericks: amalloy: you are gooder at answering this question than I am

22:30 startling: What I'm trying to do is

22:30 gfredericks: ,(doc definterface)

22:30 clojurebot: "([name & sigs]); Creates a new Java interface with the given name and method sigs. The method return types and parameter types may be specified with type hints, defaulting to Object if omitted. (definterface MyInterface (^int method1 [x]) (^Bar method2 [^Baz b ^Quux q]))"

22:30 amalloy: gfredericks: nahhhhhh, just include a Foo.java file in src/java and let lein build it

22:30 definterface is a compromise that just makes the clojure guys *and* the java guys sad

22:30 startling: have some Java code return a clojure-native data-structure rather than a Java one, since that's a little bit nicer.

22:31 (I'm writing some Java to interact with a Java library).

22:31 amalloy: startling: they can just use clojure.lang.RT/map to build a map. it doesn't have to be a record

22:34 or you can provide a clojure function that builds whatever datatype you want, from args that are convenient in java, if building a map from scratch is too hard

22:34 startling: amalloy, that's not a great solution; I'm using a defrecord since I'd like do dispatch on types.

22:34 amalloy: hm, that's possible.

22:35 amalloy: really, using a record's constructor as part of a public API is tacky, even in clojure (see: bbloom's discussions earlier today)

22:35 put a function in between and you're more flexible and more convenient

22:37 startling: that's a good point. thanks!

22:45 gfredericks: tools.nrepl has a good readme

22:45 (inc cemerick)

22:45 lazybot: ⇒ 16

22:46 * gfredericks hopes cemerick buys himself something nice with that internet money

23:20 luxbock: any help appreciated: http://codereview.stackexchange.com/questions/45796/translating-cfrm-algorithm-from-java-to-clojure-improving-performance

23:25 amalloy: luxbock: use a profiler, figure out where the time is being spent, and then focus on that area

23:26 luxbock: what's a good profiler to use?

23:27 milinda: I am using a priority-map inside a atom

23:28 but it type got changed in after couple of swap! calls

23:28 anyone has any idea what can go wrong here

23:32 bbloom: milinda: have you tried modifying your swap! calls to print out their inputs/outputs or the classes of their inputs/outputs?

23:35 milinda: bbloom: looks like the content of atom becomes nil in the middle

23:36 bbloom: I'll check whether this is a big from my side

23:39 bbloom: it was a bug in my code. Missing else. Thanks!

23:41 chare: what does {::file (file (str (io/resource-path) "/home.html"))} do in https://gist.github.com/anonymous/9884811

23:59 amalloy: well, ::file is a keyword, namespaced in the current namespace. so it returns a one-element map, whose key is :liberator.whatever/file, and whose value is a File object returned by file

Logging service provided by n01se.net