3 comments

[ 0.26 ms ] story [ 23.8 ms ] thread
It's interesting that they cite DRY as one of the reasons for refactoring the code to use closures, as it appears that in their later example of sorting, the two lambdas they pass for sorting ints and strings are identical other than type. Interestingly, it looks like that repetition could be solved by a macro that generates the function given a type. I'm not surprised super familiar with Go; I'm guessing that it doesn't have any sort of macro system that could do this, or else they would have mentioned it?
Oops, meant to say "I'm not super familiar"; my phone must have autocompleted "surprised" without me realizing, and now it's too late to edit
If I had to choose between no generics or "generics as closures" I'd vote no generics.