3 ms·
One good example is untyped constants. They form a large extension to the type system only present at compile time. It is a good example because there is an exc
by crawshaw 9y ago
One good example is untyped constants. They form a large extension to the type system only present at compile time. It is a good example because there is an excellent blog post describing them in detail: https://blog.golang.org/constants https://blog.golang.org/constants
In particular note the difference between
const hello = "Hello, 世界"
and
const typedHello string = "Hello, 世界"
one of these can be assigned to named string types, the other cannot.
As a user of Go I find untyped constants to be extremely useful. They almost always do what I want without surprise. Implementing them however, is not trivial.
A tricker example is embedding. It adds a lot of complexity to the type system. As a user, it can be a bit surprising, but I admit it is very useful.