Could anyone tell where the idea of Go's interface design originates form (or where this design was used first)?In particular the idea that any object conforming the interface is assignable to a variable of the interface type.
--
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.
-j
But it sure feels like duck typing when coding.
--
I'm not aware of any other language that combines the various features
of Go interfaces. This doesn't mean there aren't any such languages,
just that I'm not aware of any.
--
On Sun, Oct 11, 2015 at 5:38 AM, <michae...@gmail.com> wrote:
> Could anyone tell where the idea of Go's interface design originates form
> (or where this design was used first)?
> In particular the idea that any object conforming the interface is
> assignable to a variable of the interface type.
The idea that any object that implements an interface can be assigned
to a variable of the interface type is a form of structural typing.
This idea can be found in other languages like OCaml or Scala, where
you can write a function that applies to any value that supports some
set of methods. These form of structural typing can be fully checked
at compile time.
Go's interfaces were designed to solve particular problems. I was unaware of other languages that worked this way and I believe Ken was too.
-j
When I said I see Go interfaces as tagged unions, I was thinking about the implementation, not about the semantics.
-j