News for hackers. Stuff that matters.
Re:What else is in Go 1.11? by tmaly on Thursday August 16, 2018 @07:26AM (#17773685)
I would like to see a set library as part of standard library if they are going to do something more on this front.
Re:What else is in Go 1.11? by ainar-g on Friday August 17, 2018 @06:33AM (#17781706)
I would be more radical and add them as a part of the language, the way map is now. AFAIK, Wirthian languages like Pascal and Oberon all have sets as built-ins, with +, -, and * operators defined on them, and Go is heavily inspired by them.
Re:What else is in Go 1.11? by zlynx on Thursday August 16, 2018 @02:38PM (#17777388)
It seems to me that's just a map[set_key]bool
Re:What else is in Go 1.11? by masklinn on Friday August 17, 2018 @07:17AM (#17781900)
1. because you can't build opaque abstractions in Go, you have to wonder if there's a difference between having a true and a false value mapped to a key

2. because sets are significantly less useful without set-operations (intersections, unions, differences) and since go does not have user-defined generics you can't build a generic version of those (

3. because it wastes 1 byte per item (according to the comments in bmap, buckets are implemented column-major

`map[K] struct{}` would fix 3 and the second half of 1 (struct{} is a zero-sized singleton) but is somewhat less ergonomic so the impact of what's left of 1 is worse, and it doesn't solve 2 at all