type method func (*) append(n int, m anotherConcreteType, prev *)
type comparer interface {
(*) compare(*)
}
Look over the document below and see if there is any changes you would recommend.
https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjkMEgyAHX4N4/edit?usp=drivesdk
Thanks for sharing!
Competition is good, only when the Go team feels the heat of competition they will think about working on their type system seriously.
Go is hot right now just like Rails or Node.js used to be hot.
type set []T
func (s *set) append(t T) { s = append(set, t) }
a := set<string>{“hello,”, “world!”}
a := set{“hello,”, “world!”}
// the compiler says mismatched types?
a := set{“hello”, 1, map[string]string{}}
// can the compiler check for this kind of thing in all cases?
a := set{}
a = a.append(“hello”)
a = a.append(1)
// pseudorandomly pick n elements from collection T
pick(t T, n uint) []U
All forms of generics that I would love to have in Go: ...
...Go must adopt. ...
Go already has a NaCl backend which might fit the bill. See
misc/nacl/README for how to set it up. It links to a design document
(https://golang.org/s/go13nacl) with some background.
I think everybody here is aware that some people really want generics and that generics would probably be useful for everybody. Instead of restating that why not share what you think about this version of Go generics?
data2 := found.(float32) // THIS PANICS AT RUNTIME, data2 is int
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I would probably never use it, like many people who comes to Go from C.
Maybe this is unfounded, but I'm far from convinced that generics would make my experience of Go better. I'm really thinking here of, are we really sure they would make large unfamiliar codebases more comprehensible? Every feature of a language can be abused, so are they worth the abuse that they would allow?
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
Jesper,I find myself in rare but mild disagreement about your claims for stack-based virtual machines. Please have a look at this short paper about the Dis VM from Inferno: http://flint.cs.yale.edu/jvmsem/doc/inferno.ps
Back when I first learned about the diamond problem with multiple inheritance, I've known we need someone to invent the next and better thing after inheritance. I do hope somebody smarter than me is somewhere trying. Or even has succeeded.
And back when I first learned about the code bloat that could result from C++ generics/templates, I've known we need somebody invent the next and better thing after "Generators". Generators, by the way, first appeared in the 1950's, when they were considered a failure.
It's been decades, and I'm still waiting. I would like to believe the Go Authors are waiting for better solutions. Or even inventing them.
This seems deeply insightful to me.
It's not just maps, slices, append, and make. Every single operator could be considered too to be "generic" because each operates on an indefinite number of types.
But Go gains much from the special-case syntax and semantics associated with each of these language features, IMHO. I'm sure one could make a language where maps, slices, pointers, etc were all just generic types and operations. I'm sure there are many such languages already.
Swift for example has a solution that avoids code-bloat to some degree (https://www.youtube.com/watch?v=ctS8FzqcRug).