#clojure log - Dec 11 2014

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

0:07 owi: @ambrosebs hi, do you know if there's any work being done on http://dev.clojure.org/jira/browse/CTYP-167 ?

0:09 @ambrosebs I really like core.typed but this might be kind of a deal breaker for our project. Not sure how often it's gonna pop up

0:30 justin_smith: rritoch: your editor doesn't hint arg names?

0:31 munderwo: just a style thing - for let bindings you don't use for anything, the canonical binding is _

0:32 (you use temp)

0:32 rritoch: justin_smith: I'm using counterclockwise and I've never seen any type hints

0:34 munderwo: ahh thanks justin_smith

0:43 nicferrier: justin_smith: only on unix tho and I want to have this work on windows too. don't ask.

0:43 justin_smith: ouch

0:44 nicferrier: yeah.

0:44 now I gotta go to work. and it's raining.

0:44 justin_smith: wow. good luck

0:52 rritoch: Is anyone aware of a clojure library for manipulating version numbers in a standard way? Such as converting a version string into a comparable version object?

1:04 puredanger: you mean Maven coordinate type stuff?

1:06 the pomegranate lib (https://github.com/cemerick/pomegranate) wraps the underlying Aether stuff used by Maven. There is stuff in both related to this. if you don't care about Maven eccentricities it's probably far uglier than what you want

1:25 rritoch: In leiningen is there any way to load a dependency from a specific repository, or to exclude certain repositories?

1:27 puredanger: "lein sample" is pretty useful for seeing what lein supports

1:27 I do not believe you can be that specific with deps

1:27 I do think that the repos are checked in order however

1:28 a lot of people run enterprise repos like Nexus that proxy external repos and they have some facilities for this kind of thing too

1:28 rritoch: puredanger thanks. I don't explicitly include clojars in my repositories, so maybe that is the issue, I just need to change the order they're checked.

1:28 puredanger: clojars is implicit from lein

1:29 there is probably some way to exclude it though

1:29 rritoch: puredanger: Yes, but I need clojars checked first

1:29 puredanger: ah, then yes I would think including it first in the repos list would help

1:31 yeah, use ^:replace before the repositories vector to remove clojars, then re-include it as first repo

1:35 Frozenlock: Ring wrap-frame-options overrides my header :-(

1:40 rritoch: puredanger: Wow, the actual solution was much simpler, I just needed to use the correct name for the artifact. I forgot the clj- prefix so when it got to the private repositories which must be configured wrong, it was throwing errors.

1:41 puredanger: My fault for trying to work on 5 hours sleep

1:42 puredanger: Either way, thanks for the help. Those tips will likely come in handy in the future.

2:01 kenrestivo: what exactly causes cancellaton exceptions? i'm having trouble tracking down where they are comingfrom.. the stacktrace isn't terribly helpful

2:28 rritoch: Is there any way to make a lazy sequence from a java method that ends on null? I'm looking through clojure.core and the closest to what I'm looking for is the iterate function, but as far as I can tell iterate wouldn't ever end.

2:28 SagiCZ1: rritoch: there is a function called lazy-seq which lets you state how to fetch the element you want.. if you add a condition to it, you may achieve the result you want

2:28 (doc lazy-seq)

2:28 clojurebot: "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?"

2:32 noidi: (doc take-while)

2:32 clojurebot: "([pred] [pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects. Returns a transducer when no collection is provided."

2:37 rritoch: noidi: Thanks, I think that is what I need. So I should be able to (take-while identity (iterate (partial #(.getNextEntry %1 %2) zip-input-stream)) so if the file I need isn't there it will stop on nil, otherwise (using filter) I can grab the file I nead without parsing the entire zipfile.

2:39 noidi: err, that %2 isn't needed

2:39 SagiCZ1: dont forget to close the zip input stream

2:39 and the entry as well

2:41 rritoch: SagiCZ1: Won't they automatically close when I (System/exit 0) ?

2:41 SagiCZ1: This isn't a long running app. I'm just going to grab the file and run.

2:42 SagiCZ1: rritoch: yeah they would close with the jvm, definitely

2:42 rritoch: SagiCZ1: Ok thanks, either way you have a good point that I can't use this in long running apps since after I get past the filter I won't be able to close the entries.

2:44 SagiCZ1: yup.. i am actually trying to solve a similar issue.. lazy reading from zipped files and i havnt find a solution for closing them.. you can leave them open, but its good to know about it

2:46 rritoch: SagiCZ1: It may be a bit ugly, but one idea I can think of would be passing in an atom to cache every one that is read for future closing.

2:47 SagiCZ1: yeah.. that should be possible.. i may resort to that if i cant find a nice solution

2:51 rritoch: SagiCZ1: Anyhow iterate still isn't the right function, I need to use take-while and repeatedly, but at least I have a solution

3:41 tsdh: Since I've installed JDK8, I get these warnings when running "lein test" in my project. warning: Supported source version 'RELEASE_6' from annotation processor 'org.sonatype.guice.bean.scanners.index.SisuIndexAPT6' less than -source '1.8'

3:41 Is there a way to get rid of those? (Well, other than to switch to an older JDK of course)

3:48 yotsov: from 27th until when do we take care of gomboc?

3:48 oh sorry, wrong window :)

5:09 si14: what's the most idiomatic/fast/concise way to form a Clojure vector with some values that can be missing? Like [:a :b (when (pred foo) :c) :d] , but without nils inside

5:11 clgv: si14: that's not possible. if there is no meaningful value you set, the vector must at least have an entry at the position, e.g. nil or some custom :unset

5:11 si14: or do you mean the vector can be shorter when the value is missing?

5:12 ,(cond-> [:a :b] (odd? 2) (conj :c) true (conj :d))

5:12 clojurebot: [:a :b :d]

5:12 clgv: ,(cond-> [:a :b] (even? 2) (conj :c) true (conj :d))

5:12 clojurebot: [:a :b :c :d]

5:13 si14: clgv: yep, it's not possible with syntax that I've wrote there. Of course it can be something with flatten or (-> filter vec), but I was wondering if there is a better way

5:14 clgv: si14: see the examples above

5:15 si14: cond-> and true _smth_ makes it less obvious IMO than more straightforward (let [foo [:a :b] foo (if (odd? 2) (conj foo :c) c) ...] foo)

5:19 whodidthis: how do i {:a 1 :b 2 :c 3} => '([:a 1] [:b 2] [:c 3]) without messing up the order

5:20 si14: whodidthis: it's not possible, order is not defined in hashmap

5:20 mearnsh: ,(seq (into (sorted-map) {:a 1 :b 2 :c 3}))

5:20 clojurebot: ([:a 1] [:b 2] [:c 3])

5:20 whodidthis: ok, thanks

5:20 si14: whodidthis: of course, except if it's a sorted-map

5:21 mearnsh: you are implying that keys are sorted. it can be true only in the example above and not in their real code

5:23 mearnsh: true

5:28 rritoch: si14: If you want to stick with the vector syntax you can use map filter and partition like ##(mapv first (filterv second (partition 2 [:a true :b true :c false])))

5:28 lazybot: ⇒ [:a :b]

5:28 rritoch: si14: of course eaach of those true/false statements can be replaced with your actual test

5:29 si14: Using the new transducers it is probably possible to reduce this to a single function, though I haven't tried.

5:29 si14: rritoch: thanks!

5:31 rritoch: si14: I'm going to toy with transducers in repl because this seems to be an ideal case for one

5:32 si14: But I'm not sure since partition isn't really a reducer

5:33 si14: rritoch: yes, it seems so. However, I didn't think about mapv/filterv, it seems nice even like this — it bugged me a bit to perform vector -> seq -> seq -> vector for such a simple task

5:33 rritoch: So far it's not looking good... (partition 2) doesn't produce a transducer

5:47 si14: Ok using transducers you can make a function as follows...

5:48 One sec, problem with copy/paste

5:48 ,((fn [v] (into [] (comp (filter second) (map first)) (partition 2 v))) [:a true :b true :c false])

5:49 clojurebot: [:a :b]

5:50 rritoch: si14: Instead of using this as an anonymous function you can assign it as a function using def and you have a reusable, clean, transducer that is very clean to use.

5:50 si14: rritoch: thank you :)

5:53 H4ns: is there an idiomatic way to force the loading of a certain clojure file when a jar is loaded, without putting the namespace into the dependency tree of the main class?

5:54 we're building an uberjar with lots of unrelated functionality packed together, and we thought we could use some top-level function to register ourselves with the command line driver. but as the main function does not depend on the implementations for each command explicitly, the command implementations are never loaded.

5:54 we thought about using the class loader to search for certain classes, but before going that route, maybe there is a way to annotate a namespace so that it is always loaded?

5:57 tsdh: si14: Wrt. to your vector question, you could also use splicing:

5:57 ,`[:a :b ~@(when (odd? 3) [:c])]

5:57 clojurebot: [:a :b :c]

5:59 rritoch: H4ns: Are the clojure files that you plan on loading included in the jar?

6:00 H4ns: rritoch: yes

6:01 rritoch: H4ns: You could try load, I don't believe that links any dependency

6:02 H4ns: rritoch: but that'd require that i more or less know the full class name, right?

6:02 si14: tsdh: it's possible only if that predicate is known in compile time, isn't it?

6:03 rritoch: https://clojuredocs.org/clojure.core/load

6:04 H4ns: You need to know the path to the file you want to load

6:05 H4ns: rritoch: okay, that seems like a good approach, thanks!

6:14 clgv: si14: "true" was just a compromise to keep it short. in most cases cond-> is preferrable over equivalent imperative lets

6:16 H4ns: you can normally require them as well

6:26 rritoch: Is there any way to get partition 2 into a transducable function composition so it partititions the collection before applying the other functions?

6:31 clgv: rritoch: is there no implementation in 1.7-alpha? I think partition was mentioned in some clojure/conj 2014 transducers talk

6:32 rritoch: clgv: The version I'm using is based on alpha-4 and partition doesn't return a transducer

6:32 ,(type (partition 2))

6:32 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/partition>

6:32 rritoch: same here

6:33 clgv: huh

6:34 rritoch: clgv: Hmm, I see partition-by and partition-all, maybe they'll do it

6:34 clgv: rritoch: does it have a different name? since merging the transducer version with the original partition wont work due to the existing arities

6:35 rritoch: yeah they are mentioned on http://clojure.org/transducers

6:36 rritoch: but the weird thing is that (partition-all 2 1) wont work

6:36 ,(transduce (partition-all 2 1) (range 5))

6:36 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/transduce>

6:36 clgv: ,(transduce ((partition-all 2 1) (range 5)))

6:36 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>

6:37 rritoch: Yay, partition all works :)

6:37 clgv: also with 2 ints?

6:37 rritoch: ,((fn [v] (into [] (comp (partition-all 2) (filter second) (map first)) v)) [:a true :b true :c false])

6:37 clojurebot: [:a :b]

6:38 rritoch: Hmm, it should

6:38 ,((fn [v] (into [] (comp (partition-all 2 1) (filter second) (map first)) v)) [:a true :b true :c false])

6:38 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>

6:38 rritoch: Guess not

6:38 clgv: wow. that's a fail...

6:38 rritoch: I'll check alpha 4

6:39 It doesn't work in alpha 4 either

6:39 clgv: That's one reason to not combine lazy and transducer versions

6:40 it'll be a mess :/

6:44 but I guess that decision is carved in stone already

6:45 rritoch: clgv: Well they should alter the docs, I checked the source code and there's no code at all to create a transducer for any ararity > 1

6:48 clgv: rritoch: I think transducers are in fact not an addition but a breaking change. so why not produce a 2.0 with transducers in clojure.core and lazy stuff for convenience in clojure.core.lazy - maybe some other held back breaking changes (improvements/fixes) could be introduced as well

6:50 tsdh: si14: No. You can use syntax-quote also to compute stuff at runtime. It's just a syntactic sugar for a complex list/vector/map construction form.

6:52 clgv: tsdh: I'd still prefer cond-> in that case

7:00 tsdh: clgv: Matter of preference, I guess. I thing the syntax-quote version might be a bit more clear in cases the vector looks like [m o o m o m o m m o] where m means mandatory and o optional. For the m-cases, you always need a "true <whatever>" clause where you just have <whatever> in the syntax-quoted form.p

7:00 clgv: tsdh: but it adds a lot of complexity

7:00 tsdh: this also very context dependent

7:01 tsdh: clgv: Complexity in which respect?

7:01 Barley_: is there any good way to make a macro that functions like defn (and calls defn) but adds some functionality to the functions is makes (like transforms the return value)

7:02 since defn can have such a different number of arguments

7:02 tsdh: Barley_: Check out tools.macro

7:03 Barley_: Espectially tools.macro/name-with-attributes

7:03 clgv: Barley_: tools.macro as tsdh said, or checkout how the defn implementation parses the arguments

7:04 tsdh: Barley_: Yep, basically you'd end up with a let that rebinds "more" a gazillion times. ;-)

7:04 Barley_: yeah, i looked at defn and it was pretty heavy on the argument handling stuff

7:05 it's easy enough to make a defn macro that just takes the name, args and body

7:05 but add docs and preconditions...

7:05 boom

7:06 tsdh: Barley_: With tools.macro/name-with-attributes you take only [name & more] and that splices out the attr-map, the docstring, etc. for you.

7:06 Barley_: sounds good

7:06 i'll have a look

7:07 thanks

7:45 triss: hey all. I'm trying to get a soundfile in to my clojurescript app

7:46 I'm using ajax.core's GET to request the file

7:46 the responce type set for XMLHTTPRequest would be an arraybuffer

7:47 how to i set this responce type for GET?

9:08 dnolen_: cfleming: is macroexpansion in a cider release yet?

9:08 cfleming: er cursive release I meant of course

9:10 si14: clgv: thanks, I'll think about it more.

9:11 tsdh: yes, it's exactly what I was looking for. Thank you!

9:46 triss: is there a difference in how clojurescript and clojure handle atoms?

9:47 justin_smith: I doubt you would see many retries in clojurescript, if any

9:47 triss: I keep seeing an error like this: No protocol method ITransientAssociative.-assoc! defined for type cljs.core/Atom: [object Object]

9:48 justin_smith: triss: assoc! is for transients, not atoms

9:48 clgv: triss: you apply assoc! on a an atom and not on the value of the atom

9:48 triss: so i have my atom:

9:48 justin_smith: clgv: assoc! is not for atoms

9:49 ,(assoc! (transient {}) :a 0)

9:49 clojurebot: #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@4490c9>

9:49 justin_smith: ,(assoc! (atom {}) :a 0)

9:49 clgv: justin_smith: correct, I didnt claim that. I just explained the reason for the error message

9:49 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Atom cannot be cast to clojure.lang.ITransientAssociative>

9:49 dnolen_: triss: for atoms the operations are swap! or reset!

9:49 justin_smith: clgv: OK, as long as we are on the right page here

9:49 triss: ah thanks dnolen

9:50 justin_smith: clgv: "apply assoc! on an atom" makes no sense

9:50 triss: got things going now!

9:50 dnolen_: ,(swap! (atom 1) inc)

9:50 clojurebot: 2

9:50 triss: cheers guys

9:52 clgv: justin_smith: sorry I didnt mark the clojure functions. the only clojure function in that statement was `assoc!`. everything else is english words to describe how the posted error happens

9:52 justin_smith: OK

9:53 clgv: I see my misunderstanding I read "you apply" as an imperative, rather than descriptive. Text is hard.

9:55 clgv: justin_smith: :P

10:11 tmarsh: Is there a good tutorial for getting a browser connected repl for cursive anywhere?

10:29 mikerod: Cider emacs sort of question - is there a way to change the default spacing in forms from 1 space to 2 spaces. I'm not sure how to work this exactly, but basically if I have a new macro or something that doesn't get automatically matched to something hard-wired in clojure-mode indentation rules it tends to start the next line at 1 space instead of 2.

10:29 However, a `do` block starts at 2 spaces. I'd think that'd be the default, but apparently it isn't

10:30 So a macro that is intended to be written like a `do` block often is: (my-macro-name\newline<forms>)

10:30 justin_smith: mikerod: there is a file that defines the styles, and defines the forms that get the custom styles

10:30 mikerod: justin_smith: I have messed with those extensions

10:30 it looks like I have to set each macro manually

10:31 to behave like `do` to get my 2 spacs

10:31 that isn't necessarily ideal

10:31 especially when it isn't able to understand an aliased symbol vs a referred vs a fully-qualified

10:31 justin_smith: perhaps you could write an elisp function that detects "do-macros" and does the update when you open the source file?

10:31 mikerod: I actually think it is odd that the default "block" style indentation doesn't align with a `do` block. I'm wondering if this is falling back to some lisp-mode rules

10:32 justin_smith: Not sure on that account. Could be.

10:32 mikerod: justin_smith: I could try that. I was hoping for a solution that's like "just set this var to 2" haha

10:33 I'll keep digging. I have been reading through it slowly. I'm no elisp expert, but picking up.

10:34 justin_smith: mikerod: you could use a special comment or metadata literal that is easy for the elisp to find, maybe

10:34 or just make a comment on the top line with the elisp code to load, that's a feature that already exists

10:35 but it would only help if you loaded the file defining those macros, of course

10:36 stuartsierra: Elisp: (define-clojure-indent (my-custom-macro 'defun))

10:36 mikerod: justin_smith: hmm yeah I think I see what you are saying

10:36 stuartsierra: yes, I have figured out to do explicit settings like that

10:36 stuartsierra: There's a global setting too but I forget its name.

10:36 mikerod: stuartsierra: it didn't seem to understand alias vs qualified vs unqualified was one issue. also I wanted a different "default" when it didn't know what to do because I had not implicitly defined it yet

10:37 clojure-defun-style-default-indent looked promising

10:37 it actually kind of worked, but then it stopped using some of the other good indentation rules that were defined for other forms :P

10:37 that's probably why it is nil by default

10:39 justin_smith: mikerod: have you tried changing the value of lisp-indent-offset

10:39 that seems to be the top level default

10:39 or a quick glance leads me to believe that at least

10:42 mikerod: justin_smith: just tried it. it actually did do what I wanted within an unknown symbol. however, it was destructive to the other rules that clojure-mode is using so don't think it'll be the magic to solve the issue for me.

10:42 EvanR: ,(type #"")

10:42 clojurebot: java.util.regex.Pattern

10:42 justin_smith: mikerod: you could redefine the preset ones from clojure-mode.el

10:44 ordnungswidrig: is there a plugin for leiningen to graph the (conflicting) dependency versions?

10:44 I only found plugins to graph the ns dependencies

10:44 mikerod: justin_smith: yeah, I think I'll just keep diggin in clojure-mode to see if I can isolate the 1 space calculation

10:48 EvanR: is there a way to change the "magic" of the regex patterns, so for example period is really a period unless you put a backslash period, in which case its any (non-newline) char

10:51 wink: wait..what?

10:52 ordnungswidrig: EvanR: java.util.regex.Pattern/quote

10:54 EvanR: ,(re-matches (java.util.regex.Pattern/quote #"ab.d") "abcd")

10:54 clojurebot: #<ClassCastException java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to java.lang.String>

10:54 EvanR: ,(re-matches (java.util.regex.Pattern/quote "ab.d") "abcd")

10:54 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern>

10:54 EvanR: ,(re-matches (re-pattern (java.util.regex.Pattern/quote "ab.d")) "abcd")

10:54 clojurebot: nil

10:54 justin_smith: EvanR: you are so close!

10:55 EvanR: ,(re-matches (re-pattern (java.util.regex.Pattern/quote "ab\\.d")) "abcd")

10:55 clojurebot: nil

10:55 justin_smith: https://clojuredocs.org/clojure.core/re-pattern <- see also the advanced usages here for specifying other options inside a regex

11:00 ordnungswidrig: ,(re-matches (re-pattern (java.util.regex.Pattern/quote "ab.d")) "ab.d")

11:00 clojurebot: "ab.d"

11:01 EvanR: yes but "ab\\.d" wont match "abcd"

11:01 like the vim "no magic" option

11:02 basically, if i was reduced to providing users with a regex option, it seems like it would be easier for them to use a no magic regex and have to use \ to use special features

11:02 ordnungswidrig: EvanR: (quite "ab\\.d") would match "ab\\.d"

11:03 EvanR: yeah i got that

11:03 rather than quoting i was referring to reversing the magic

11:03 ordnungswidrig: EvanR: well, java's regex work like most of the regex implementations worked since the beginning of time

11:03 crash_ep: Different regex flavors. Clojure uses Java's flavor, and Java's flavor doesn't have a "Vim-compatible" mode.

11:04 EvanR: im not sure thats true, but after realizing that clojure is dependent on whatever underlying hosts regex do, nevermind

11:04 crash_ep: ordnungswidrig: that statement betrays your youth! :)

11:04 ordnungswidrig: well, you can implement a preprocessor the escapes and un-escaped what's necessary

11:04 crash_ep: :-P

11:04 crash_ep: ordnungswidrig: Java's flavor is very modern compared to POSIX and other older regex flavors.

11:04 EvanR: i might be crazy but not that crazy

11:05 ordnungswidrig: crash_ep: but I never heard of a flavor that matches * and . literally by default

11:05 justin_smith: EvanR: counter-evidence: you opted to mess around with regex

11:05 ordnungswidrig: crash_ep: I'm not talking about all the other details and fancy stuff like negative look-ahead assertions (if java has that at all)

11:06 EvanR: true my specific use case doesnt even involve anything but a direct string match

11:06 justin_smith: evanr why not use the string match and skip the regex then?

11:06 ordnungswidrig: justgreg: +1

11:07 EvanR: justin_smith: i was preempting a project-managerial request to allow regex too

11:07 justgreg: ordnungswidrig, huh?

11:07 justin_smith: ,(.indexOf "hello world" "world")

11:07 clojurebot: 6

11:07 ordnungswidrig: justgreg: opps, this was meat to go to justin_smith

11:08 justgreg: no worries. I don't have opinions to +1 on clojure. :p

11:08 justin_smith: EvanR: compromise: allow regex or vanilla matching, with the ability to select which is wanted? that's easier than changing regex parsing rules

11:08 crash_ep: EvanR: scope creep

11:09 EvanR: in my project, my position right now could be described as twenty miles deep in scope creep

11:09 FriedBob: Only 20?

11:09 EvanR: more than zero means something

11:10 but yeah forget regex

11:22 Rhainur: oh man, I am so stuck right now

11:23 can someone help me figure out how to integrate cemerick/friend into a Luminus app?

11:23 the documentation seems kinda...weird

11:26 schmir: Rhainur: I've a working integration with an ldap server

11:27 using basic auth

11:37 Psy-Q: i'm writing a small HTML crawler and it should be able to move to the next page and parse that for n links, e.g. i give it a depth of 10, it should stop trying to get to the next page after 10 recursions and return the hash of what it's found. how would i go about doing that? i have a parser for one single page in place: https://github.com/psy-q/vinylla/blob/master/crawler/app/src/app/core.clj

11:39 ordnungswidrig: Psy-Q: you want to limit the depth of the search?

11:41 Psy-Q: ordnungswidrig: i'd be happy if i just knew how to check for the presence of a next page link and then recursively parse that next page (even infinitely) as a start

11:41 i know the CSS of the next page link, that part is fine. but i don't know how i would manage that state (which page i'm on, whether it's been parsed already, what the next page link is, whether to follow it...)

11:43 ordnungswidrig: Psy-Q: as you're already using enlive, in your case you'd need to check for a link with id "test_NextPageTop"

11:43 crash_ep: frequently you pass that state into a function, along with the data you want to parse, and then in the function you look at the state and decide whether or not to recur

11:44 ordnungswidrig: Psy-Q: and, btw., please follow the restrictions in robots.txt

11:44 Psy-Q: crash_ep: so it would be fine to pass something like {:current 1, :maximum 10} and recur until current == maximum?

11:45 ordnungswidrig: Psy-Q: I would pass in the remaining depth and bail out on zero

11:46 crash_ep: Psy-Q: Right, and each time you recur, you adjust the value of :current

11:46 Psy-Q: ordnungswidrig: ah yes, no need to track two vars

11:46 ordnungswidrig: Psy-Q: and maybe use core.async to queue the request and have a worker pool fetching from that queue

11:47 Psy-Q: ordnungswidrig: the whole /shop is helpfully not blocked in robots.txt, thank you though

11:47 ordnungswidrig: :)

11:47 Psy-Q: ordnungswidrig: yeah, i will have to learn about all that. the implementation i had in another language just sequentially did everything, but both my brain and that language don't do threads easily. so i never bothered.

11:48 it will be so much fun to marshal all that stuff back into a relational database

11:49 making sure to update only those records that need it. whee.

11:50 ordnungswidrig: Psy-Q: well, simply use the relation database as a backend for datomic :-P

11:51 mgaare: has datomic gotten better at storing long strings?

11:52 Psy-Q: ordnungswidrig: i'd prefer something that just helps me stuff things into postgresql with me not having to worry about details :(

11:52 but i guess that doesn't exist. the fewer magic components, the better, but the more i need a brain (which is hard to find)

11:53 ordnungswidrig: what about korma?

11:53 Psy-Q: i looked at that briefly (and some other helpers and libraries) but i've yet to try them

11:54 it could be just fine. also because maybe i'll build a little service around it that spits out json

11:54 * ordnungswidrig needs to pop out...

11:54 Psy-Q: i could use korma both ways

11:54 mgaare: Psy-Q: I've had good luck with honeysql as well

11:55 Psy-Q: mgaare: thanks

11:55 will try both i guess, i have the luxury to be doing something very small and specific, so i can do three implementations :)

11:57 EvanR: serialize the entire thing and put it in one postgres blob ;)

11:59 mgaare: one simple way, store the html as a string, store the hash of the string, and compare against the hash to see if you need to update the record

12:03 bja: serialize the whole thing and write it to /dev/null for maximal performance!

12:12 ticking: Is there a proper way to `pr` a clojure record and read it as a cljs record and vice versa, without explicitly setting a reader name. The cljs records seem to be namespaceless and afaik it is bad style to have namespaceless reader tags.

12:12 justin_smith: bja: mongodb might sue you for a patent violation if you do that

12:13 mdrogalis: justin_smith: lol

12:24 arrdem: anyone tried using object.copy to duplicate a multimethod?

12:24 wondering if this is an evil way to share most of a multimethod or a Good Idea.

12:28 EvanR: can i get a sequence of letters rather than numbers

12:28 ,(range "a" "z")

12:28 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>

12:29 EvanR: ,(char-range \a \z)

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

12:29 ordnungswidrig: EvanR: ,(map char (range (int \a) (int \z)))

12:30 ,(map char (range (int \a) (int \z)))

12:30 clojurebot: (\a \b \c \d \e ...)

12:30 EvanR: can i easily go past 26 letters?

12:30 ordnungswidrig: EvanR: hm?

12:30 into the latin1 charset?

12:30 EvanR: "y" "z" "aa" "ab" or something

12:33 ordnungswidrig: EvanR: you can with BigDecimal and a radix greater than 10, I think

12:33 EvanR: heh

12:33 ordnungswidrig: EvanR: or clojure.math.combinatorics and some string mapping maybe

12:34 EvanR: ill just make it crash if it tries to go past 26 for now

12:34 TimMc: "for now"

12:48 arrdem: being able to generate utf8 glyphs with a char range would be .... interesting

12:48 I'm pretty sure test.check's character generators will do utf8

12:48 you could look and see how those work..

12:49 EvanR: this is completely decorative, so it really needs to look right, rather than be any sequence of different strings or chars

12:50 so im writing a function to convert a number into base 26 with the alphabet a to z

12:50 fun

12:53 as for unicode chars... id expect this to work #(char 210)

12:53 ,(char 210)

12:53 clojurebot:

12:56 EvanR: oh how do i get a backwards sequence

12:56 ,(range 8 1)

12:56 clojurebot: ()

12:56 EvanR: reverse?

12:57 justin_smith: &(range 8 1 -1)

12:57 lazybot: ⇒ (8 7 6 5 4 3 2)

12:58 EvanR: hmm &(reverse (range 0 8))

12:58 ,(reverse (range 0 8))

12:58 clojurebot: (7 6 5 4 3 ...)

12:58 EvanR: lazybot is better

13:13 sdegutis: Be there any way to derive the executing function's var and/or name?

13:16 srobinson: sdegutis: I don't suppose you've tried dotrace? I think you have to call it higher up the stack

13:16 sdegutis: I haven't.

13:17 This link suggests throwing an exception and getting the name from that: https://groups.google.com/forum/#!topic/clojure/ORRhWgYd2Dk

13:17 srobinson: sdegutis: I found it on StackOverflow http://stackoverflow.com/questions/2352020/debugging-in-clojure

13:18 sdegutis: srobinson: My gratitude.

14:06 EvanR: well im glad i made it go past 26 since on my first test run i went to 28

14:09 justin_smith: &(print (char 9731))

14:09 lazybot: ⇒ ☃nil

14:09 sdegutis: ,(char 9731)

14:09 clojurebot: \☃

14:09 EvanR: excel should switch row numbering immediately

14:10 sdegutis: ☃/*\☃

14:10 EvanR: columns rather

14:10 if youll direct your attention to column snowman

14:14 amalloy: sdegutis: of course at any given time there are many functions which are "currently executing".

14:14 sdegutis: amalloy: I need the deepest one in the stack

14:14 amalloy: okay, and if it doesn't have a name?

14:14 sdegutis: Or rather the caller of the function which gives me this string/var.

14:14 amalloy: then nil

14:14 justin_smith: that's easy: the one that tells you the name of the executing function!

14:15 amalloy: sdegutis: what i'm getting at is that there's no way to tell apart anonymous functions from named functions, if all you have is a stacktrace

14:15 well, maybe not "no way". you can always look at their names and guess

14:15 er, their classnames

14:15 sdegutis: Thanks.

14:18 cfleming: dnolen_: No sorry, I parked that - it won't be in the next drop but I'll try to get it in the one after. Still not sure how the UI should work.

14:20 seangrove: cemerick: Just to be sure, I'm not actually expecting you to fix my car

14:20 cemerick: I'll be alright with just the backrub

14:20 Just wanted to be clear, I don't want to come across as entitled

14:20 cfleming: tmarsh: Here's a message from a Cursive user about how he did it: https://www.refheap.com/94762

14:21 tmarsh: cfleming: thanks!

14:21 cfleming: tmarsh: No worries, all credit goes to Wilker for that one

14:21 dnolen_: cfleming: ah k, well definitely a must have for me, working on core.match nearly impossible w/o. Granted not everybody else is dealing w/ macros like core.match.

14:22 cfleming: dnolen_: Yeah, I understand. How important is correctly supporting &env to you?

14:23 dnolen_: That makes it trickier but not impossible, just needs more thought.

14:23 dnolen_: cfleming: I would count that as a "nice to have"

14:23 cfleming: dnolen_: Ok I'll try for a dumb one first and add that later.

14:24 dnolen_: You also need selective expansion of subforms, right? Do you need full expand or expand-1 for those, or ideally both?

14:24 dnolen_: cfleming: that's also another "nice to have"

14:25 cfleming: dnolen_: Ok, most important is full expand?

14:25 dnolen_: Just pretty printed source is all I really need to not go crazy

14:25 cfleming: dnolen_: Ok got it.

14:25 Bronsa: dnolen_: btw the core.match AOT issue is definitely CLJ-979 -- the current patch doesn't address that case but I'm working on it

14:26 dnolen_: Bronsa: k cool

14:27 cemerick: seangrove: I promise, you'd appreciate the car repair more :-P

14:27 seangrove: cemerick: Heh, hope no one's getting to you too badly

14:28 cemerick: seangrove: Nah. I was pretty shocked by the first (the one I screenshotted). Been more amused than anything else by those that followed.

14:29 I suppose it's possible I was getting trolled, in which case my recent tweets are sweet victory for them :-P

14:41 TimMc: cemerick: yikes

14:42 Bronsa: dnolen_: yup, bug fixed

14:43 dnolen_: http://dev.clojure.org/jira/secure/attachment/13602/CLJ-979.patch here's the patch if you want to try it out

14:44 puredanger: Bronsa: I did get the ok to work on that btw, just have been clearing other stuff first

14:44 the ok to clean it up enough for consideration I should say

14:44 Bronsa: puredanger: nice, I just updated the patch -- it now fixes a longstanding AOT bug for core.match

14:44 puredanger: cool

14:49 Bronsa: puredanger: I believe my last patch for CLJ-979 solves most of the issues around bad interaction between JIT and AOT, CLJ-1457 OTOH is somewhat related to the transitive compilation stuff

14:49 IOW CLJ-979 should in theory solve all the classloader issues

14:50 cemerick: TimMc: ?

14:50 puredanger: Bronsa: that's all I ask

14:52 TimMc: cemerick: Just looking over the tweets in question.

14:52 Bronsa: puredanger: let me know if you have any issues whenver you get to work on it, I'd really like to see this one in 1.7. I'm growing tired of AOT issues :P

14:52 puredanger: for sure

14:58 Bronsa: puredanger: nice work on CLJ-1515 btw. have you found out why the new chunked range is slower than the current clj version?

14:59 puredanger: there is no simple slower/faster if you look at those numbers

15:00 I have a newfound appreciation for like the third time for how fast chunking can be :)

15:01 the Java object version has a bit more overhead than the clojure version. the 1515 version is faster for reduce and optimizes the all-long case which makes up for the overhead

15:03 Bronsa: puredanger: ah, trivial suggestion: s/AbstractRange/ARange to be consistent w/ the current clojure naming?

15:03 puredanger: I think in general what's in the patch makes most of the common cases faster. In some smaller ranges, the overhead dominates but in those cases the times are fast enough to be unlikely to be important.

15:04 non-long cases are rare and are still not much worse without chunking

15:04 Bronsa: cool

15:04 puredanger: I found adding chunking to the non-long version made it noticeably slower

15:04 so yeah, the original 20 lines of Clojure code was pretty great :)

15:05 re naming, might be a good idea

15:05 Ghadi already found a bug in it so I've got do more changes anyway

15:05 Bronsa: puredanger: that's not fair, it's 20 lines of clojure + ~250 of java for LazySeq

15:05 puredanger: true. but now it's like +600 more lines of Java :)

15:06 s/20 LOC Clojure/600 LOC Java/ = :(

15:06 probably a fair chance Rich looks at the whole thing and tells me to go home :)

15:06 Bronsa: right. having protocols available earlier in the bootstrap process would help immensely

16:07 andyf: Eastwood is gradually getting quieter. Next: audio renditions of warnings in quiet gravelly voice.

16:10 TimMc: :-D

16:11 Voiced by Tom Waits, please. Thank you.

16:12 TEttinger: http://youtu.be/jlKUa5X2H1w?t=3m32s

16:12 andyf: "So the question you've got to ask yourself is: did you call that macro with 5 arguments or 6? In all the confusion, I lost track myself."

16:12 TEttinger: haha we thought of the same thing

16:13 or you're a very fast typist and listened to that clip very quickly

16:16 ucb: TEttinger: truckfighers? \o/

16:16 truckfighter*

16:16 ssssss

16:25 Frozenlock: ugh... when I uberjar my compojure project, the home address "/" returns an empty response. Does this ring any bells?

16:26 (it works when using 'lein run')

16:26 justin_smith: Frozenlock: are you accessing any templates using file operations where you should be using resource operations?

16:28 Frozenlock: justin_smith: No, the home page is all in a .clj file with hiccup formatting.

17:40 PaulTS: Need help with lein deploy clojars

17:40 I'm trying to deloy a jar directly.

17:41 I'm stuck at signing the jar and pom for promotion.

17:42 If I sign each (pom and jar) with gnupg (publick key is in my profile) I get an error.

17:43 Ex: is sign with: 'gpg --sign pom.xml'

17:44 I get pom.xml.gpg.

17:44 Can't upload this without error even if I change the name of the file to remove the .gpg.

17:45 Using the following command: lein deploy clojars cawala/i2p 0.9.17-4 i2p.jar pom.xml

17:47 justin_smith: the pom.xml.gpg should just be a signature, that would upload separately from the pom.xml

17:50 PaulTS: Hmm, doesn't appear to be, by the command above, but I can probably create a detached signature.

17:51 justin_smith: PaulTS: I could be wrong. I thought it was a question of building a detached sig. #leiningen may be a better place to get the info on this.

17:51 PaulTS: Thanks, I'll give that list a shot.

18:22 ed-g: Hello everyone. I'm looking for a way to set an HTTP header value in all Ring responses. Is there an available middleware for this or should I build my own using ring.util.response or the like?

18:24 amalloy: ed-g: isn't it just (defn add-header [handler header value] (fn [req] (assoc-in (handler req) [:headers header] value)))?

18:24 there's probably an existing middleware, but honestly it's so simple i wouldn't even bother looking for one

18:31 EvanR: can you destructure lists in function parameters

18:33 amalloy: ~tias

18:33 clojurebot: tias is try it and see

18:34 EvanR: unsupported binding form

18:34 ed-g: amalloy: thanks!

18:35 justin_smith: ,((fn [[a b c]] c) (range)) ; EvanR

18:35 AimHere: EvanR, Doesn't work for me, but if you treat it as a vector, it'll happily accept a list

18:35 clojurebot: 2

18:35 amalloy: EvanR: what did you try? paraphrased error messages with no source or stacktrace are not useful

18:35 EvanR: (let [(a b) '(1 2)] b)

18:35 alright, converting to vector

18:35 justin_smith: yeah (a b) is not a destructuring syntax

18:36 arrdem: huh. totally could be tho.

18:36 justin_smith: arrdem: why would it be useful?

18:37 I mean it's not like [a b] constructs a vector form the input or anything

18:37 amalloy: arrdem: it's nice that () is an available syntax for alternate meanings

18:37 EvanR: well in many ways the regular lists are useless simply because no one cares about them, so theres no way to conveniently use them

18:37 its like, just dont use lists in the message

18:37 justin_smith: EvanR: the [a b] destructuring syntax does not mean "expect a vector"

18:37 arrdem: (with-irony (dec lists))

18:37 EvanR: oh

18:38 justin_smith: it means "destructure a sequence"

18:38 EvanR: so it should fail on a map &(let [[a b c] {:a 1 :b 2 :c 3}] b)

18:39 justin_smith: right

18:39 arrdem: justin_smith: really? there isn't an implicit (seq) in there that could make it work?

18:39 amalloy: arrdem: no

18:39 justin_smith: the syntax for mid-message lazybot usage is ##(let [[a b c] {:a 1 :b 2 :c 3}] b)

18:39 lazybot: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap

18:40 justin_smith: &((fn [[a]] a) "abc")

18:40 lazybot: ⇒ \a

18:45 charlespwd: Does anyone has experience setting up ssl on a ring app? I'm confused.

18:45 amalloy: ~anyone

18:45 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

18:45 justin_smith: better to set up ssl on nginx, and use that as a reverse proxy

18:46 nginx has security features none of the java/clojure servers have

18:46 weavejester: Yep, I just use nginx

18:46 charlespwd: Thanks. I'll look into it.

18:46 weavejester: Putting a HTTP server behind nginx and letting it handle the SSL is a common pattern in most languages nowadays.

18:46 charlespwd: amalloy: Gotcha. Sorry for vague question.

18:47 amalloy: charlespwd: turns out i was wrong, in a way: folks were enthusiastic enough to answer anyway

18:48 justin_smith: amalloy: unlike most "anyone" queries, the solution to his problem was implicit in the question

18:48 charlespwd: weavejester: < just starting out. Great to know.

18:49 marrrk: I would like to use kioo with chestnut, but just adding [kioo "0.4.1-SNAPSHOT"] to the dependencies in project.clj seems not to be enough. What am I doing wrong?

18:50 justin_smith: marrrk: that should suffice to add kioo to the classpath so that you can require the namespace and use its functions. But you do have to do the latter still.

18:51 marrrk: do I have to first "get it" somehow?

18:52 justin_smith: marrrk: the project.clj makes sure it is present

18:52 next step is to require the namespaces that kioo provides

18:52 then call the functions it makes available

18:52 see "Quicstart tutorial" on the kioo github page. https://github.com/ckirkendall/kioo#quickstart-tutorial

18:56 marrrk: Okay, I broke something independent of that

19:00 PaulTS: &("hi)

19:00 lazybot: java.lang.RuntimeException: EOF while reading string

19:00 justin_smith: PaulTS: fairly new to clojure?

19:01 PaulTS: not really

19:01 marrrk: Great, it works, thanks

19:01 PaulTS: new to irc

19:01 &("hi")

19:01 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

19:01 PaulTS: &(println "hi")

19:02 lazybot: ⇒ hi nil

19:02 justin_smith: PaulTS: OK, that was a remarkable density of bugs for such a small program, is why I asked

19:02 PaulTS: hehe

19:41 Frozenlock: weavejester: I recently added ring-defaults to my compojure apps, and now my homepage returns an empty response in the uberjarred app. Any ideas what might be causing this?

19:43 weavejester: Frozenlock: Without knowing more about your app I couldn't say.

19:44 Frozenlock: okay, I'll continue digging.

20:18 weavejester: I think I found it... looks very much like this https://github.com/noir-clojure/lib-noir/issues/107

20:20 weavejester: Frozenlock: It could be the content-type if you're not setting it, though I'm not sure whether that would return a blank page.

20:53 Frozenlock: Which version of Ring/Compojure are you using, out of interest?

20:53 Frozenlock: [ring "1.3.2"] [compojure "1.3.1"]

20:54 weavejester: Frozenlock: Do you have anything in your deps that would load an older ring-core?

20:54 Frozenlock: lein deps :tree to be sure

20:55 dnolen_: BOOM, https://github.com/clojure/core.match/commit/fabf2552bc46d7d73646c98459c5d7fe5ed2fd15

20:56 weavejester: dnolen_: Oh, that's interesting

20:57 Frozenlock: weavejester: Some plugins and Friend seems to be using 1.2

20:57 weavejester: dnolen_: I've been using core.match more recently, and really quite liking it

20:58 Frozenlock: Do they override the version from Ring?

20:58 Frozenlock: If you add an explicit dependency to [ring/ring-core "1.3.2"], does that fix the problem?

20:58 Frozenlock: I'm thinking you might be running into a bug in wrap-resource.

20:59 dnolen_: weavejester: glad to hear it!

20:59 weavejester: dnolen_: Incidentally, what's the status on a core.match equivalent to multimethods? :)

21:00 dnolen_: I seem to remember the possibility was considered a while ago.

21:01 dnolen_: weavejester: heh not sure when I'll have time for that, just focusing on finishing touches to 0.3.0 and then I'll be busy with cjls.test and cljs.pprint

21:02 weavejester: dnolen_: Does cljs.test pull in anything from cemerick's library?

21:02 dnolen_: weavejester: does not - he decided to copy over some things I don't agree w/ like dynamic binding

21:03 which is gnarly for async tests

21:03 plus cljs.test is built on stuff anyone can hook into for their own testing framework

21:03 weavejester: dnolen_: clojure.test is pretty ancient and gnarly with regards to dynamic binding etc.

21:03 dnolen_: yes

21:04 clojure.test & clojure.pprint are extremely useful - but eye sores too.

21:04 weavejester: dnolen_: I agree

21:05 dnolen_: Out of interest, how hard would it be to adapt core.match with multimethod like behavior? Couldn't you just store the match forms in an atom, and recompile them with eval every time a new method is added or removed?

21:06 dnolen_: weavejester: that's right something like that, however you have to deal w/ ordering issues

21:06 Frozenlock: weavejester: well dang, I think it works... I explicitly added ring-core and updated lein-ring. I will check which one was causing the problem.

21:06 dnolen_: weavejester: probably solvable just haven't had time or incentive to look myself

21:06 gotta run, feedback welcome on core.match :<< usage

21:06 weavejester: dnolen_: Bye

21:07 Frozenlock: I think you had an older version of ring-core, and that had a bug where directories in uberjars weren't correctly recognised.

21:10 Frozenlock: Looks like it, recompiling with only the ring-core specified still works.

21:21 weavejester: thank you very much. Updated the issue on github, hopefully this will also help others.

21:35 uris77_: Anyone having issues fetching the closure compiler from clojars.org? I'm getting this error:

21:35 Could not transfer artifact com.google.javascript:closure-compiler:jar:v20140625 from/to central (https://repo1.maven.org/maven2/): GET request of: com/google/javascript/closure-compiler/v20140625/closure-compiler-v20140625.jar from central failed

22:26 jayp498: Hi all, was wondering if someone could help me in writing a small macro "add-params-to-fun". Here is a small Gist that explains what I have and what I want: https://gist.github.com/jayp/ece9035fea0aa2d31926

22:26 Any help would be greatly appreciated ;-)

22:31 sm0ke: jayp498: what are you trying to do here?

22:31 cant you use apply instead?

22:32 jayp498: I have a function that takes a lot of parameters, I want to create another function that tags some additional parameters.

22:32 sm0ke: jayp498: you can use (partial...) ?

22:33 ,((partial + 1 2 3) 4 5 6)

22:33 clojurebot: 21

22:34 sm0ke: jayp498: the problem is (+ 5 6) is not a function while #(+ %1 %2) is

22:34 jayp498: i did that, but was a bit ugly: (let [foo (partial + 1 2 3) bar (foo 4 5 6)] ((foo)))

22:34 sm0ke: ,(defmacro ap [f & a] `(~f ~@a))

22:34 clojurebot: #'sandbox/ap

22:35 sm0ke: ,(ap #(+ %1 %2) 1 2)

22:35 clojurebot: 3

22:35 sm0ke: but then again this will fail for

22:35 ,(ap (+ 1 2) 3 4)

22:35 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

22:35 sm0ke: you see the problem here?

22:36 jayp498: hmm

22:36 In by foo bar example, I want to execute foo and bar in the let body. bar is basically an addition to foo. The thing is that foo is also parameterized

22:37 Hmm, I may have to simplify my approach, if what I am intending to do is not so straight forward

22:37 sm0ke: ,(let [foo (partial + 1 2 3) bar (foo 4 5 6)] bar)

22:37 clojurebot: 21

22:37 sm0ke: i dont see the problem here

22:38 ,(let [foo (partial + 1 2 3) bar (foo 4 5 6)] [bar (foo)])

22:38 clojurebot: [21 6]

22:38 sm0ke: ok so you want to get rid of the parens around foo?

22:38 jayp498: sm0ke: I gave a simpler example, but foo is more like #(baz "hello" "world" %1)

22:39 mgaare: jayp498: this satisfies what you put in the gist at least:

22:39 (defmacro add-params-to-func [f & params] (list (first (drop-last f)) (concat (last f) params)))

22:40 jayp498: mgaare: thanks. let me play around.

22:40 sm0ke: i am not very sure about this, its not like you would be doig ((((((((fooo))))))))

22:41 its always going to be a function call (fooo)

22:41 jayp498: give me a couple minutes. I can update the gist with my actual use. Maybe you can just give me pointer on how to simplify.

22:42 mgaare: ok

22:51 Can someone help me with an aleph/gloss/manifold problem? I seem to be having a stupid - http://pastebin.com/LuVnFcga

22:53 jayp498: smoke mgaare: I updated the gist. the function send-email is simplified in the gist, but in real use has a lot more params. Basically I am writing test code with small variations in optional parameters.

22:54 oops, I meant sm0ke

22:59 sm0ke: jayp498: there is no currying in clojure, so i still think partials is the most elegant way to solve this

23:00 jayp498: ok

23:00 mgaare: jayp498: can you put an example usage of that macro? I'm not sure exactly what

23:00 you're going for

23:00 sm0ke: mgaare: he just want to chain functions with extra arguments

23:00 jayp498: btw, mgaare the macro def you provided has a small mistake

23:00 sm0ke: on each step

23:01 jayp498: i can live with partials

23:01 sm0ke: jayp498: https://clojuredocs.org/clojure.core/letfn

23:01 jayp498: just wanted to do some macro magic

23:01 haha

23:02 sm0ke: jayp498: letfn will make it more succinct i guess

23:03 mgaare: jayp498: what was wrong with my macro? :D

23:03 oh I se

23:04 justin_smith: I think you wanted cons in the place of list

23:04 nd in place of concat too actually

23:06 mgaare: it was the first that was screwing it up

23:06 jayp498: yeah

23:06 but you know what

23:06 even then it's messed up

23:07 mgaare: this works, although it' sugly

23:07 (defmacro add-params-to-func [f & params] (concat (drop-last f) (list (concat (last f) params))))

23:07 justin_smith: what is f?

23:07 jayp498: #(+ %1 %2)

23:07 ,(defmacro add-params-to-func [f & params] (list (drop-last f) (concat (last f) params)))

23:07 clojurebot: #'sandbox/add-params-to-func

23:08 mgaare: some function where you want to add some things to the last form

23:08 justin_smith: yeah, (concat (last f) params) won't fly then

23:08 jayp498: ,(macroexpand '(add-params-to-func #(%1 %2) 7 8 9))

23:08 clojurebot: ((fn* [p1__52# p2__53#]) (p1__52# p2__53# 7 8 9))

23:09 jayp498: ,(add-params-to-func #(%1 %2) 7 8 9)

23:09 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: p1__78# in this context, compiling:(NO_SOURCE_PATH:0:0)>

23:09 jayp498: I am getting the same thing

23:09 It seems the variable p1__xy# is lost by the time it executes

23:09 mgaare: hrm, was working at the repl for me

23:09 justin_smith: look at the expansion

23:09 the fn has an empty body

23:10 jayp498: the expansion looks good. no?

23:10 justin_smith: then it's local bindings are in a list after it

23:10 no, it does not

23:10 jayp498: ,'#(+ %1 %2 3 4 5)

23:10 clojurebot: (fn* [p1__105# p2__106#] (+ p1__105# p2__106# 3 4 ...))

23:10 justin_smith: ((fn [a b]) (a b))

23:10 mgaare: oh, that's the old one

23:10 justin_smith: above I added white space to show the problem more clearly

23:11 mgaare: ,(defmacro add-params-to-func2 [f & params] (concat (drop-last f) (list (concat (last f) params))))

23:11 clojurebot: #'sandbox/add-params-to-func2

23:11 mgaare: ,(macroexpand '(add-params-to-func2 #(+ %1 +2) 3 4 5))

23:11 clojurebot: (fn* [p1__158#] (+ p1__158# 2 3 4 ...))

23:12 jayp498: thanks justin_smith

23:13 justin_smith: ,(macroexpand '(add-params-to-func2 #(identity) 1))

23:13 clojurebot: (fn* [] (identity 1))

23:13 mgaare: doesn't work with more than 1 form though

23:13 jayp498: I am going to stick with partial for now

23:13 It's something I can grasp

23:13 mgaare: (macroexpand '(add-params-to-func2 #(let [more "forms"] (+ %1 %2)) 3 4))

23:13 ,(macroexpand '(add-params-to-func2 #(let [more "forms"] (+ %1 %2)) 3 4))

23:13 clojurebot: (fn* [p1__207# p2__208#] (let [more "forms"] (+ p1__207# p2__208#) 3 4))

23:14 justin_smith: well, it did add things to the let body

23:14 mgaare: obvious product of 2 minutes and minimal thought :D

23:15 jayp498: mgaare thanks for your help

23:15 mgaare: jayp498: yw, good luck

Logging service provided by n01se.net