Re:Neugram – Scripting in Go
by crawshaw on Saturday November 04, 2017 @07:44AM
(#15624609)
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
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.
In particular note the difference between
and 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.