Re:Go Proposal: first-class support for sorting slices
by masklinn on Tuesday August 16, 2016 @12:45PM
(#12298677)
> interface{} is the new void*.
More like Java's Object, especially since downcasts are mandatorily runtime-checked. And the results are exactly what one could have expected from the first 10 years of java (if slightly subdued as Java only had a single magical blessed buildin type) given the language is in more or less the same class.
Re:Go Proposal: first-class support for sorting slices
by mseepgood on Tuesday August 16, 2016 @02:12PM
(#12299346)
More like C#'s "object" than Java's "Object".
Re:Go Proposal: first-class support for sorting slices
by leaveyou on Tuesday August 16, 2016 @01:13PM
(#12298919)
>interface{} is the new void*
There is an important difference between interface{} and void* which makes it a lot less reckless. AFAIK interface{} contains not only a pointer to data but also a reference to the type of the data. Therefore you can cast that data safely to the original type (or use "switch" on the type). if origData, ok := data.(OriginalType); ok { /safe to use origData here*/ }
There are far better ways to handle generics in modern languages, which preserve type safety and aren't very cumbersome.