Fork me on GitHub
#clojure-uk
<
2020-10-22
>
jiriknesl03:10:07

Good morning

dharrigan06:10:47

Good Morning!

dharrigan09:10:55

Style question, when using type hinting (for interop stuff), do people perfer this

dharrigan09:10:37

(defn foobar ^FunkyReturnType
      [some-magic-variable]
      ....

dharrigan09:10:58

(defn foobar
   ^FunkyReturnType
   [some-magic-variable]
   ....

seancorfield16:10:46

@dharrigan I just checked our code and it looks like we mostly follow a third version:

(defn foobar
  ^FunkyReturnType [some-magic-variable]
  ...

👍 3
dominicm17:10:23

^ I like that one

dharrigan09:10:43

type hint on same line or separate line of the defn name

alexlynham10:10:31

separate lines if you do args on separate lines prob?

mccraigmccraig10:10:39

mild preference for separate lines

dharrigan10:10:46

I think I'll go with separate lines, as yes, my variables are on a separate line

Ben Hammond10:10:03

I prefer alot of short lines because it make stacktraces more precise to diagnose what bit actually went wrong

Ben Hammond11:10:34

and often enough a stacktrace is all you have got to go on...

dominicm11:10:53

@dharrigan neither. Same line as args.

dharrigan13:10:17

ah, so you would have something akin to:

dharrigan13:10:33

^FunkyReturnType [some-magic-variables]

dominicm11:10:19

You can have different return type per arity, so the type isn't on the function per se.

alexlynham13:10:57

ah good i see boris whipped the tories to block free school meals over school holidays

alexlynham13:10:22

a really good look at a time of already acute food poverty x coronavirus crisis

alexlynham13:10:06

imagine getting up in the morning, looking in the mirror and going 'yes i am the sort of person that actively wants children to be hungry'

alexlynham13:10:10

what a motivator eh

dharrigan13:10:54

I don't think Boris would see his reflection in the mirror

😆 9
Ben Hammond15:10:19

yeah hes got a picture of a mirror; and that picture shows the reflection of Chris Tarrant

Ben Hammond15:10:52

so he lives his life blissfully unaware

seancorfield16:10:46

@dharrigan I just checked our code and it looks like we mostly follow a third version:

(defn foobar
  ^FunkyReturnType [some-magic-variable]
  ...

👍 3
seancorfield16:10:18

(with a "docstring" on the line(s) between the function name and the return type/args)

dharrigan17:10:28

cool, thank you.