Fork me on GitHub
#clojure
<
2016-04-13
>
tomjack05:04:41

and there is no metadata for edn, generally..

tomjack05:04:22

you'd have to be discouraged from using the lift-ns for anything interesting. and in case it was not obvious, (comp read print read) converts some 'normal' maps into 'fixed-lift-ns' ones...

tomjack05:04:38

the print part without the read part seems much less troublesome and could be done outside core

stijn09:04:50

does anyone know of an example on how you would use/alter clojure.core.cache asynchronously?

carocad10:04:36

does somebody has some knowledge of core.reducers? I noticed that r/map and r/filter have arities to return "transducers" but if I do (into [] (comp (r/map inc) (r/filter odd?)) (range 10)) it returns an error 😕 any ideas on this? thanks 😄

loganmhb12:04:47

@carocad: I’m not a reducers expert, but it looks like r/map and r/filter are curried rather than returning transducers

loganmhb12:04:18

this works: (into [] ((comp (r/map inc) (r/filter odd?)) (range 10)))

loganmhb12:04:37

(probably not what you want though)

pesterhazy13:04:06

I came up with this fn to group a seq of maps by multiple keys: https://gist.github.com/pesterhazy/2b99f520f48ff2673c86e3b11f4480d2 Any way to improve this?

danielstockton13:04:38

To override cons on a custom deftype, should i just need to implement a cons method against clojure.lang.IPersistentCollection? I can't seem to change the default behaviour.

base69815:04:18

is it legit to do something like:

(fn [coll]
   (let [meta (atom {})]
     (mapcat #(... modify meta, if one thing do something, if another do something else) coll)))

base69815:04:39

is that idiomatic? Or is there a better way to track that kind of state.

jr15:04:42

what kind of state do you want to track?

base69815:04:32

it's if it's seen a particular key

base69815:04:25

if it hasn't it does an interpolate vs just return the point on a line

donaldball15:04:08

Every once in a blue moon I resort to side effects from a loop or reduction within a fn, though nowadays I (ab)use volatiles when I do since I don’t need the atomicity guarantee

base69815:04:51

volatile would work since it's just one state/run per call

donaldball15:04:06

It’s probably good practice if you’re still developing your clojure aesthetics to at least make a game attempt to solve it only with immutable data structures

base69815:04:06

I actually did, with a reduce, but to break the reduce up into two smaller maps this is the only way I could do it

base69815:04:18

i'm trying to make it more readable for a Java dev

base69815:04:46

only way I could think to do it

mrwhite15:04:24

Hey peeps! How do you debug clojure code? Is there a toot allows debug in java way?

akiva15:04:15

What’s your dev environment? (I’ve not coded Java so I’m not sure what the ‘Java way’ is.)

mrwhite15:04:07

I'm on intellij idea.

base69815:04:09

and it's not java way

akiva15:04:19

Hmm. I’ve not used IntelliJ either.

akiva15:04:29

But you should learn the Clojure way rather than trying to do things the Java way.

mrwhite15:04:57

@akiva: there's no question about that.

akiva15:04:13

But, yes, CIDER is generally the Clojure way: http://cider.readthedocs.org/en/latest/debugging/

mrwhite15:04:21

OK. Got it.

mrwhite15:04:10

I'm sorry for that noise. Just need a quick patch to do. Pretty nervous %)

akiva15:04:24

No problems. If you’re new to Clojure, there’s also a #C053AK3F9 channel.

psalaberria00215:04:40

@mrwhite: I would recommend Cursive if you are using intellij. It has a nice debugger.

zzamboni17:04:24

@akiva thanks for that link about debugging, very useful!

hlship17:04:34

Under 1.8, which clojure namespaces are compiled with direct linking? I was under the impression that it was just clojure.core, but I’m seeing behavior that makes me think others (for example, clojure.stacktrace or clojure.test) may be direct linked.

hlship17:04:41

Starting to peek at some decompiled bytecode ...

hlship17:04:23

The decompiled code for (defmethod clojure.test/report :error) invokes clojure.stacktrace.print_cause_trace/invokeStatic() directly, following the direct linking pattern. Is this intentional?

hlship17:04:46

You can see this in class clojure.test$fn__7906.

hlship17:04:16

This affects how io.aviso/pretty and clojure.test operate (it disables pretty’s ability to provide an alternate implementation of print-cause-trace).

hiredman17:04:14

likely everything in the clojure jar is direct linked

hiredman17:04:48

it is all aot compiled in one step in the clojure build, likely with the same settings

hlship17:04:15

That is problematic. I may have to change pretty to do a (load “/clojure/test.clj”) after it alters the root of print-cause-trace.

hlship17:04:24

i.e., to bypass AOT and direct linking.

hlship17:04:44

Experimenting: (RT/loadResourceScript "clojure/test.clj”) gets the job done.

ghadi18:04:34

that's a rather large hammer

rmuslimov18:04:27

Can’t get spyglass memcache library to work, it returns nil even value 100% in memcached

rmuslimov18:04:20

And here is clj code returns nil,

rmuslimov18:04:34

Somthing trivial that I miss here?

rmuslimov18:04:13

btw, lf is locahost

rmuslimov18:04:48

However if I set value from spyglass, it visible

rmuslimov18:04:04

if I set value from other client it is not, weird

akiva18:04:51

Does anyone even use letfn?

akiva18:04:43

I try to avoid it because it just seems to make the code appear messier but I think I have a use case for it to encapsulate a predicate that’s only used in one function.

majenful19:04:20

I’ve installed cryogen. I want to customize the template and have a picture at the top of my page. So I put it in base.html, but when I go to another page, for example archives, the image is broken

majenful19:04:10

because picture is src=« img/pic1.png »>. However archives page extends base.html, it should work

jballanc19:04:36

Anyone know if it’s possible to join two symbols in a quasi-quote without a space between?

jballanc19:04:39

e.g.:

(def a ‘foo-)
(def b ‘bar)
`(~a~b) ;;=> (foo- bar)
but I really want (foo-bar)

jballanc19:04:00

I realize I can do (symbol (str (name a) (name b))) but that seems
ugly

loganmhb19:04:35

@jballanc you could do (symbol (str a b)) (or your version with name). Without some sort of function called on the two values the symbols are going to be separate forms to the reader (hence the whitespace).

jballanc19:04:40

Hmm
I suspected as much. Was hoping their might be some trick of splicing unquote that would make it work.

jballanc19:04:58

Funny that C preprocessor macros can do it, but Clojure macros can’t
oh well

ghadi19:04:24

no "trick", you just eval something inside a syntax-quote

ghadi19:04:51

~(symbol (str a "-" whatever))

taylor.sando19:04:17

You could use format,

~(symbol (format "%s-%s") (name a) (name b))
though I'm not sure you're getting much more by doing it.

Tim20:04:41

is there a way in clojure.test to apply a fixture to all namespaces (not just one)?

Matthew Davidson (kingmob)22:04:30

Does anyone know of a way to force loading of files? I have multimethods whose definitions are in multiple files, but nothing directly "require"s them, so the files aren't being loaded, it seems.

seancorfield23:04:13

Could you just add them to the :requires in a file that relies on them?