Interfaces
This is one of the areas with the largest difference from Go.
Built In and Operators
The built in types will have methods. The operators are defined as methods. This means that you can define interfaces that will include the built in types.
See Operator Methods
Unions
This is a tagged union, like the Enum from Rust
type IntN union [ int8 int16 int32 int64 ]
What makes it an interface is that any method shared by all members is a method on the union.
Coercion
Not sure about this, but I would like returns on concretes to be coerced to more general types and arguments to be coerced to more specific types. So
func Foo(s *MyStringer) IFooer
on an interface would match
func Foo(s Stringer) Foo
on a concrete.
However, I think the syntax should be explicit to allow coercion, so maybe
func Foo(s <*MyStringer>) <IFooer>
or
func Foo(s ~*MyStringer) ~IFooer
One of the cases where I want this is for graph structures.
type BinaryTreeNode <
elem interface{
<Less(elem) bool
}
>interface{
Parent() Null<BinaryTreeNode>
Left() Null<BinaryTreeNode>
Right() Null<BinaryTreeNode>
Value() elem
mut Insert(elem)
}