5 ms·
> The type system literally straddles the dynamic and > static The Go type system is fully static...
by sagichmal 13y ago
> The type system literally straddles the dynamic and
> static
The Go type system is fully static...
- nostrademons 13y agoGo has an escape hatch (interface{} and downcasts) that basically give it an embedding of a dynamic type system inside the static one. You end up having to use this a lot if you're doing things like decoding complex JSON data structures or working with containers, since Go doesn't have generics.
- masklinn 13y ago> Go has an escape hatch (interface{} and downcasts) that basically give it an embedding of a dynamic type system inside the static one. No, that gives you a static type system with loopholes, same as Java, you have to use reflect to get a dynamic system in which you can invoke an arbitrary and unchecked method on an object (also same as Java). Granted, because Go's type system is structural you could define an interface with just the method(s) you want, cast your object to that interface and then call the methods, and you can even define the interface anonymously and inline. Still, go requires your static types to match unless you use reflect.