Fork me on GitHub
#clojure-uk
<
2018-07-17
>
yogidevbear06:07:00

I might need a

dominicm06:07:20

@manas.marthi what has you up so early?

alexlynham06:07:56

Morning morning

thomas07:07:48

mogge 😼

dominicm09:07:14

The example involving def is great

guy10:07:23

Morning!

alexlynham10:07:57

in that as-> example above, the pattern I was shown was declaring a partial inline

alexlynham10:07:48

so if you declare a partial it returns an fn and you then just make sure the arg you want is the first of the restargs

dominicm11:07:58

We actually avoid partial, and use #() always.

alexlynham11:07:55

any reason for avoiding partial?

alexlynham11:07:02

or do you mean, just in threading?

alexlynham11:07:14

because comp + partial is a pretty useful thing...

alexlynham11:07:37

altho I guess transducers are now the hot new newish thing 🙂

dominicm11:07:47

We avoid it because it makes the arguments extremely opaque, and also something about "haskell people" 😜. I think that #() does make it clearer how the function is expected to be called.

danm14:07:35

Yeah, we do the same. The few places we've used a fn with different ordering inline of a thread we've used #()

alexlynham11:07:47

so you mean you'd wrap the fn you want in a higher order #() construction?

firthh11:07:38

I actually prefer partial to #(), I find it easier to reason about, I know that it was the first args that have been curried and usually implies you’ve thought about the order of args. Whereas #() you could have curried curried any of the args to the function and I need to read closer which ones you’ve curried

👍 4
dominicm11:07:39

@firthh interesting, I have the opposite mentality. I immediately have to figure out which arities the callers of the f will be using, and it is a pain. Where as with #() I know exactly what is expected.

4
firthh11:07:09

Interesting, I suppose #() is more explicit

dominicm11:07:57

I like explicit 🙂 My code is horribly verbose.

dominicm12:07:32

I even dislike conveniences over consistency like [clojure.string :as str] vs [clojure.string :as string]. Always the latter!

thomas12:07:25

While I like explicit I suspect I might go for the former ^^

alexlynham12:07:54

I'll hold my hands up and say I probably would go for the former there :)

dominicm12:07:06

I don't understand why string is special and is renamed to str when everything else is just has clojure. dropped off the front.

alexlynham12:07:15

I dunno, a lot of the clj I've seen gets ns's crunched down to as few chrs as possible

dominicm12:07:06

yeah, I see that too. It confuses the hell out of me. In one ns my.cool.app.models is models/ and in another my.cool.app.db.models is models/, I can't cope with the congitive overhead.

dominicm12:07:33

I want ONE alias per project, don't care if it's long, I have auto-complete for that.

dominicm12:07:27

The other one is utils, web-utils :as utils then app.utils :as utils I just, urgh!

alexlynham12:07:37

yeah so that's a good example

alexlynham12:07:51

bc I've seen a lot of code where that would be

alexlynham12:07:02

:as wu :as au

dominicm12:07:54

The correct answer is [app.models :as models] and [my.cool.app.db.models :as db.models]

rickmoynihan10:07:11

nice, I don’t know why I never thought of using a . in an alias before. I’d used -’s for the same effect. Will definitely adopt this convention.

rickmoynihan10:07:51

strange I hadn’t picked up on that, as I’d read the stu sierra post.

dominicm12:07:10

(correct to me of course, pushing my grumpy perspective on the world)

guy12:07:28

[app.models :as models] as [app.models :as mooodles]

guy12:07:41

:thumbsup:

alexlynham12:07:36

idk I tend to think as long as it's consistent within a project, it's whatever rolls off the keyboard and reads best

👍 4
💯 4
alexlynham12:07:36

in most cases that'll be the full word, but sometimes if it's better to be terse then I'll take wu au dbio fio or whatever

3Jane12:07:49

Separately, having read the original threading with style…

3Jane12:07:09

Don’t you think that what he calls a blackboard / context map is simply procedural namespace?

alexlynham12:07:25

and tbh if I'm only using it once in a ns (e.g. a fn in clojure.string) I'll sometimes just use the full path, clojure.string/join or whatever

guy12:07:00

i don’t really like that tbh

guy12:07:15

I would prefer to require it then everyone else knows where its coming from

danm14:07:21

If the full path is in the body of the code then surely you still know where it's coming from. If anything an alias makes it less clear, because you have to go and check the ns aliases.

danm14:07:25

But it is a handy shorthand

guy19:07:09

you’re right yeah

dominicm12:07:39

@alex.lynham you require it first though right? 😄

alexlynham12:07:04

well, if it's in the project deps then it's available to you via that path

alexlynham12:07:26

(unless I've misunderstood yr question 🙂 )

dominicm12:07:37

no it isn't. You have to require a namespace before using it.

dominicm12:07:40

Else it might not be loaded.

alexlynham12:07:18

hm, looking through source code it looks like I'm lying, it is required and I don't really see a case where I've got it as a full path

dominicm12:07:55

java classes work how you describe.

alexlynham12:07:56

though I did find an example of terse requires

alexlynham12:07:23

because it's not io but you want to signal that the other namespace is the input and output boundary of your program

alexlynham12:07:58

bc :as io isn't included in that ns but it's used elsewhere in the project

alexlynham12:07:14

contrived example maybe

guy12:07:35

i would opt with that too

guy12:07:46

ncio is not as nice as http://needlecast.io

alexlynham12:07:42

ah that's because I don't like the . character in an alias

alexlynham12:07:00

...which sounds irrational when you write it down

alexlynham12:07:06

but it's not, I promise 🙂

alexlynham12:07:13

(okay, maybe a little bit)

🙈 4
😂 4
dominicm12:07:32

I'd go with http://nc.io if I was using it a lot.

alexlynham12:07:45

I'll go with the grain of the project but yeah probably prefer the shorter one. If other people got upset in review I'd either use the longer one or

alexlynham16:07:44

Just when I thought my thing was working, it looks like the db transaction is rolling back silently...

alexlynham16:07:06

this is definitely a job for first thing in the morning with fresh coffee

8