Question: then it's generics isn't it?

Asked By
Asked At
2017-08-22 16:46:42

Found 15 possible answers.

User Answered At Possible Answer
exbigboss 2017-08-22 16:46:48 Nope
e-dard 2017-08-22 16:46:58 func() string is a different type to func() int for example
exbigboss 2017-08-22 16:47:23 That’s true but just because the result of decltype changes with your function doesn’t mean it’s generic decltype is just a way of saying, get me the type of this function’s return The return type of my_func is always known
e-dard 2017-08-22 16:48:13 I would ague that a type that stores differing but known types is a generic type :slightly_smiling_face:
exbigboss 2017-08-22 16:48:32 I believe you are conflating meta-programming with generics
e-dard 2017-08-22 16:48:37 but I'm no type system exper Probably I am
exbigboss 2017-08-22 16:48:56 In this case, it’s not generic because you aren’t writing a function that takes an arbitrary type Instead, for example you’re creating a slice of whatever the return type of a particular function is
e-dard 2017-08-22 16:49:30 Oh I see, well I missed that part.
exbigboss 2017-08-22 16:49:32 And in Go, the return type of a function is always known
e-dard 2017-08-22 16:49:43 I was assuming you were putting different functions into the same container...
exbigboss 2017-08-22 16:49:49 It’s “meta-programming” because you’re writing code based on the code you wrote
e-dard 2017-08-22 16:50:02 i.e., element 1's function returns and int and element 2's function returns a string
exbigboss 2017-08-22 16:50:20 Oh, yeah, not that lol :stuck_out_tongue: Those alone would go a long way towards making your code easier and safe to refactor Ooh, maybe Go doesn’t need generics but instead needs meta-programming tools
zsx1234 2017-08-22 16:54:18 in a way we do have generics, but its decoupled I been putting a lot of thought into functions with interfaces params, its more clear that the function is wanting a type that implements X,Y,Z functions generic functions vs golang functions that take interfaces. []MyType vs List<
thurt 2017-08-22 17:02:28 hey guys, anyone know a good tutorial for logging go programs? i have a couple go programs that do http communication and run on a cron timer, i would like to understand best practices for logging results of these programs

Related Questions