News for hackers. Stuff that matters.
Re:Go 1.11 and Beyond by dilatedmind on Saturday August 25, 2018 @05:01PM (#17842547)
Not without either implementing it yourself or wrapping interface methods.

Go generate is like a manual step for having generics, I imagine one day soon its functionality or something similar will be part of go build.

In response to your particular example, a map plus a mutex seems sufficient.

I dig that it's a few extra lines of code, but I guess I'm looking for a really mean example.

Re:Go 1.11 and Beyond by coldtea on Saturday August 25, 2018 @09:21PM (#17843649)
>I dig that it's a few extra lines of code, but I guess I'm looking for a really mean example.

Well, if you don't care about repeating yourself, mistakes by omission, needless boilerplate, and/or loss of type safety, then, sure, everything is possible in "a few extra lines of code" in a turing complete language...

Re:Go 1.11 and Beyond by lederhosen on Saturday August 25, 2018 @05:44PM (#17842733)
I can not create a really mean example because Go is Turing complete. That means that everything can (with a few extra lines) be expressed in Go.

The problem with your mutex solution is at least two:

1) it is more complex

* more lines to type and read and check and thus harder to understand

* you can forget the mutex

* if you have data structures of hastables, you will have to pass mutexes around or store them together with the tables.

2) it is not nearly as performent as a lock free hash table

(edit indentation)

Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @03:21AM (#17844730)
Back when Borland C++ 2.0 came out for MS-DOS, templates were still being designed.

So the first version of BIDS, Borland's C++ data structures library, used pre-processor tricks where one defined the types before including the respective data structure.

So go generate as workaround feels quite old.