Fork me on GitHub
#clojure
<
2016-06-16
>
patrkris09:06:57

I see clojure.spec uses "named arguments" in several places (e.g. (clojure.spec/fdef :args ... :ret ....)). Is there any convention as to when to use named arguments vs. a map? Maybe named arguments are primarily used for macros?

dominicm10:06:13

@patrkris: You might have luck in #C1B1BB2Q3

patrkris10:06:25

I'll give it a try 🙂

gfredericks11:06:00

patrkris: my impression is that named arguments make more sense for things humans will be typing, compared to functions that are called programmatically

gfredericks11:06:44

I don't have the sense that existing APIs with named arguments are primarily macros, but now that you bring it up I could see that being a general design principle since macros are also aimed at being used by humans

stuartsierra12:06:59

yes, anything that might be generated programmatically is better left as a map.

zaffy16:06:55

I am a newbie and looking for help with clojure/cljs

zaffy16:06:43

are there any working sample apps using relational db and reagent?

seancorfield16:06:50

(it doesn’t include a relational DB but covers a lot of the front end stuff)

casperc16:06:54

I am wondering, why isn’t it possible to add metadata to keywords? It would be very useful i think.

seancorfield16:06:12

When we were building Reagent apps backed by a DB, we used Sente (core.async channels over WebSockets) to communicate between the front end and back end /cc @zaffy

seancorfield16:06:15

@casperc: keywords are simple, efficient things that can be compared for identity quickly — metadata would break that.

casperc16:06:47

Isn't metadata is ignored for identity?

seancorfield16:06:07

@casperc: keywords are fast to compare because there’s only one :foo — to support metadata, each :foo would have to be separate.

Alex Miller (Clojure team)16:06:15

Right, keywords don't (and won't) have metadata because they are shared

casperc16:06:35

I see. I think I understand.

seylerius19:06:09

Why on earth would simply adding a lib as a dependency break cider?

seylerius19:06:23

I'm having a serious WTF moment...

seylerius19:06:55

Well, I can probably work around the need for conch and just use clojure.java.shell instead. Can a call to clojure.java.shell/sh be wrapped in a future, and would that lead to it writing to the StringWriter I provide as the :out parallel to my existing process?

bfabry19:06:39

@seylerius: we found using the new ProcessBuilder API the easiest way to do that, if you're on a newish java

seancorfield19:06:14

@seylerius: Did you check whether conch introduces dependency conflicts?

seylerius19:06:20

bfabry: I'll take a closer look at that. Thanks for reminding me.

seylerius19:06:58

@seancorfield: Didn't check that. Good possibility.

seylerius19:06:13

@seancorfield: Depends on clojure 1.6.0. There we go.

seylerius19:06:34

@bfabry: I'll have to try ProcessBuilder.

seylerius19:06:55

Also, anyone tried seesaw with Clojure 1.8 yet?

seylerius19:06:13

Or are there any more recently updated alternatives to seesaw?

brian_mingus20:06:38

why does lein new reagent foo give me an ancient core.async dependency? [org.clojure/core.async "0.1.346.0-17112a-alpha"]

seancorfield20:06:53

@seylerius: And it works if you add :exclusions [org.clojure/clojure] to your me.raynes/conch dependency?

lvh21:06:28

huh; can I extend an existing java type to behave like a map, in that I can look up keywords in it?

lvh21:06:42

I thought you could but it looks like ILookup is an interface, not a protocol.

lvh21:06:56

hiredman: Yeah, so only by wrapping it. OK, I guess that’s fine

lvh21:06:34

hiredman: I kinda wanted the original type to be able to participate, but I guess I just had Lookup in my head as a protocol instead of ILookup the interface

hiredman21:06:49

yeah, but having a library named "wallhack" for accessing private fields takes some of the sting out of wrapping

josh.freckleton21:06:58

Sorry to interrupt this discussion, I've got a quick question about clojure libs which depend on java libs. I'm trying to use Factual/geo, https://github.com/Factual/geo, and including the dependancy in project.clj doesn't seem to be enough to get it working, I'm thinking it's not compiling correctly and/or lein hasn't even downloaded the java libs to be compiled. Any thought on what I might be missing?

josh.freckleton21:06:44

(specifically, it can't locate geo/whatever on classpath)

hiredman21:06:18

what did you put in your project.clj?

hiredman21:06:43

it should pretty close to [factual/geo "1.0.0"]

lvh21:06:05

@hiredman: incidentally my test strings for this class were already “iddqd” and “idkfa” so I guess wallhack is OK

josh.freckleton21:06:17

@hiredman: that, exactly, [factual/geo "1.0.0"]

hiredman21:06:58

and what namespace are you trying to require? and do you have a stacktrace of the error (assuming the error is indicated via an exception)

hiredman21:06:09

have you restarted your repl since you added that to your project.clj?

josh.freckleton21:06:04

deleted a stack trace because it was a huge block of noise on this thread

josh.freckleton21:06:32

I have restarted the repl

hiredman21:06:34

your require form is incorrect in some way

josh.freckleton21:06:52

I've tried their suggested: (require '[geo [geohash :as geohash] [jts :as jts] [spatial :as spatial]])

josh.freckleton21:06:10

[geo.spatial :as spatial]

josh.freckleton21:06:05

(require '[geo.spatial])

hiredman21:06:31

what happens if you run lein repl in your project, then type (require '[geo.spatial]) in to the repl?

josh.freckleton21:06:45

java.io.FileNotFoundException: Could not locate geo/spatial__init.class or geo/spatial.clj on classpath.

josh.freckleton21:06:00

(from fresh repl too)

hiredman21:06:36

are you sure when you added the dependency to your project.clj you added it to the correct project.clj and in the correct place?

josh.freckleton21:06:57

oh fml, emacs jumped straight to a project.clj but from another project. I added the dep to the wrong project. thanks for helping me through my own idiocy, and it works now!

jsa-aerial21:06:11

@seylerius: I use conch just fine on clojure 1.7 and 1.8. Cider is fine as well. Maybe some other toxic interaction going on??