admin-announcements

Announcements from the Clojurians Admin Team (@U11BV7MTK @U077BEWNQ @U050TNB9F @U0ETXRFEW @U04V70XH6 @U8MJBRSR5 and others)
2015-11-06T09:05:45.000040Z

Hi Everyone!

ian 2015-11-06T09:09:01.000041Z

Hello, @mrjaba

luposlip 2015-11-06T10:47:03.000043Z

yo @mrjaba

2015-11-06T10:49:12.000044Z

Hi :simple_smile:

dominicm 2015-11-06T13:14:16.000047Z

Is there a way to write a macro which would expand to two adjacent constructs?

dominicm 2015-11-06T13:14:47.000048Z

e.g. if it was in a {} and you called it, it could expand to both the key and the value?

dominicm 2015-11-06T13:19:02.000049Z

Actually, a function might be fine, as I can evaluate all the arguments. But I still need to expand it out somehow.. Hmm.

moxaj 2015-11-06T13:29:13.000050Z

@dominicm: you could try (apply hash-map your-stuff)

dominicm 2015-11-06T13:30:35.000051Z

@moxaj: For sure, not the best example on why. I'm actually trying to expand out 2 arguments of a library, which can be in any number of places, AND need to be mixed with a lot of others.

dominicm 2015-11-06T13:31:58.000052Z

Basically, I'd want a macro that looked something like this:

(defmacro x
    []
    :key :value)
and an example usage:
{:foo :bar 
   (x)}
and would compile to:
{:foo :bar
   :key :value}

moxaj 2015-11-06T13:34:46.000055Z

@dominicm hmm, maybe (apply assoc ..) ? (apply assoc {:foo bar} [:key :value])

dm3 2015-11-06T13:35:58.000056Z

it's only possible to return a valid clojure symbol/form

dominicm 2015-11-06T13:36:12.000057Z

@moxaj: But I'd also want it to work elsewhere, e.g. (myfn (x)) => (myfn :key :value)

dominicm 2015-11-06T13:36:32.000058Z

@dm3 So I can't return multiple?

dm3 2015-11-06T13:36:35.000059Z

no

dominicm 2015-11-06T13:37:24.000060Z

Shame. Hmpha, I'll have to find another way to do this then.

dm3 2015-11-06T13:37:56.000061Z

what exactly is the problem? do you want to have a user write {:x 1, (bar)}?

dominicm 2015-11-06T13:41:11.000062Z

@dm3 So, there's a function consuming keys & values as [& {:keys [x y z]}], and I want to expand in a few to cut down on repetition, mostly because the key/value are mixed (as in, the key contains part of the value)

dm3 2015-11-06T13:43:12.000063Z

you can call it with (apply your-fn [:x 1, :y 2]) if that helps

dominicm 2015-11-06T13:45:53.000065Z

I suppose that would allow me to compose them.. yes. I wish this library allowed the call as a hashmap, then I'd just have to merge the two!

dominicm 2015-11-06T14:17:25.000067Z

@dm3 heh, no apply for me, as the target is a macro, not a fn.

dm3 2015-11-06T14:18:01.000068Z

now you see why you shouldn't write even more macros :simple_smile:

dominicm 2015-11-06T14:18:32.000069Z

I didn't write the original macro, it's actually enlive! I thought I'd have better success than this.

2015-11-06T14:18:33.000070Z

in macros &form is available

2015-11-06T14:18:43.000071Z

it gives you the enclosing form, eg {}... so you could do this

2015-11-06T14:18:58.000072Z

i've never seen it done, maybe it's bad, but it might be awesome

dominicm 2015-11-06T14:19:05.000073Z

https://github.com/cgrand/enlive/issues/136 I've opened an issue, hoping someone has something specific to my scenario.

2015-11-06T14:19:11.000075Z

actually i guess it's not possible because of the even-numbered entries the reader requires

dm3 2015-11-06T14:21:28.000079Z

but snippet is also a macro..

dominicm 2015-11-06T14:24:15.000080Z

The macro hole goes deep

dominicm 2015-11-06T14:24:26.000081Z

And way beyond my comprehension.

dominicm 2015-11-06T14:27:47.000082Z

But, in general, this is why macros are bad, and you should always provide a form which takes a plain ol' map.

dominicm 2015-11-06T14:30:34.000083Z

@dm3 I'm using bouncer, just saw this > Hats off to @dm3 for this pull request.

dm3 2015-11-06T14:37:42.000085Z

:simple_smile:

dominicm 2015-11-06T15:00:54.000087Z

I wonder if it's too late for me to just throw out enlive, and use hiccup. Hmm..

2015-11-06T15:07:16.000088Z

Hello there, any reason to still use use ? In brave clojure book, daniel use it but I saw an blog article on 8thlight that use is now useless since Clojure 1.4 ?

dominicm 2015-11-06T15:07:47.000089Z

@majenful: Use has been deprecated & replaced pretty much.

dominicm 2015-11-06T15:08:02.000090Z

Better to use (require '[name.space :refer :all])

dominicm 2015-11-06T15:08:08.000091Z

I'm surprised it's still in brave clojure.

2015-11-06T15:08:47.000092Z

I may miss a sentence like « just to illustrate, don’t use it », but in my ebook version he speaks about it

2015-11-06T15:10:29.000093Z

"require and use ensure that a namespace exists and is ready to be used, and optionally let you refer and alias the corresponding namespaces. You should use ns to call require and use in your source files. https://gist.github.com/ghoseb/287710/ is a great reference for all the vagaries of using ns."

2015-11-06T15:10:50.000094Z

from => http://www.braveclojure.com/organization/

dominicm 2015-11-06T15:12:56.000095Z

Ah, it looks like he's opted to cover everything. But the recommended way to import everything from a namespace is now :refer :all

alexmiller 2015-11-06T17:20:40.000101Z

the only time I use use is at the repl when I'm hacking b/c it's shorter

roberto 2015-11-06T17:32:32.000102Z

oh, that is one of my pet peeves. Documentation that uses use.

2015-11-06T19:38:24.000110Z

hello everybody

2015-11-06T19:38:45.000111Z

i got a coworker trying to get clojure up and running and he seems to be bumping into the issue captured in this gist

2015-11-06T19:39:03.000113Z

lein repl command hitting a ' java.lang.IllegalArgumentException: array element type mismatch' exception

2015-11-06T19:39:13.000114Z

anybody see this before?

markmandel 2015-11-06T21:07:15.000116Z

@johangrufman: I'm guessing,, it's some bad syntax somewherre

markmandel 2015-11-06T21:08:03.000117Z

Go back to a known stable state - get the repl working, then load the new code into the repl

markmandel 2015-11-06T21:08:06.000118Z

that will highlight it

2015-11-06T21:17:26.000120Z

In a new folder, does "lein new app spork; cd spork; lein repl" also cause a java.lang.IllegalArgumentException?

gnejs 2015-11-06T21:36:18.000122Z

hi all!

ffreire 2015-11-06T21:54:10.000123Z

Hi @gnejs!

2015-11-06T21:55:04.000124Z

ahoy

gnejs 2015-11-06T21:57:29.000125Z

Anyone "going" to Clojure Remote?