News for hackers. Stuff that matters.
Re:Half a decade with Go by pjmlp on Tuesday November 11, 2014 @05:53AM (#8589249)
> Because of the implicit thing!

Known as structural typing and available in most modern languages.

Re:Half a decade with Go by icebraining on Tuesday November 11, 2014 @06:27AM (#8589319)
available in most modern languages

Well, "modern" is an ill-defined concept. As far as I'm aware, structural typing is not really that common, is it? Besides OCaml and Scala, is there any relevant (used outside of academia) language that supports it?

Re:Half a decade with Go by pjmlp on Tuesday November 11, 2014 @06:50AM (#8589378)
D and C++ templates for example.

F# also supports it, given its ML linage.

C# tricks with dynamic, although in this case it is dynamic typing, so not really the same thing.

Re:Half a decade with Go by seabee on Tuesday November 11, 2014 @07:14AM (#8589441)
The disadvantage of C++ templates is the structural type is implicit - you only know if the input object satisfies the type if you read the documentation, code, or can decipher the error message that occurs if it didn't.

Concepts would have fixed this, but we don't have concepts and maybe never will!

Re:Half a decade with Go by pjmlp on Tuesday November 11, 2014 @08:20AM (#8589626)
> Concepts would have fixed this, but we don't have concepts and maybe never will!

enable_if and type traits are a workaround for the time being.

Concepts lite will definitely be in the next revision.

Re:Half a decade with Go by losvedir on Tuesday November 11, 2014 @08:08AM (#8589588)
Would rust's "traits" count as structural typing? (I know Rust may not count as "relevant (used outside of academia)" yet, but maybe in the future.)
Re:Half a decade with Go by tel on Tuesday November 11, 2014 @08:51AM (#8589734)
Haskell's typeclass provide it.
Re:Half a decade with Go by dragonwriter on Tuesday November 11, 2014 @10:28AM (#8590242)
Typeclasses aren't structural typing, they are nominative typing, as typing is controlled by explicit declaration of relations between types and typeclasses, not inferred from structural properties.
Re:Half a decade with Go by tel on Tuesday November 11, 2014 @11:12AM (#8590533)
Sure they are: (forall a. X a => a) is a supertype of (forall a. (X a, Y a) => a).
Re:Half a decade with Go by dragonwriter on Tuesday November 11, 2014 @09:28PM (#8593676)
I stand corrected.