Is there an expression form to "upcast" a value of concrete type to an interface type?
I am noodling on my own hobby programming language similar to Go in some respects. One aspect my language shares with Go is that there is no subtyping but types are assignable to interface types.
Now I'm trying to work out the syntax for that assignability. In Go, I know you can assign a concrete type to an interface type using a variable declaration:
type Concrete struct {
n int64
}
type Abstract interface{}
func main() {
var x Abstract = Concrete{1} // <--
}
This works, but requires you to write a statement and be in a position where you can do so. Is there a corresponding expression form that accomplishes the same thing? As far as I can tell, the answer is no. Type assertions are only used for "casting" the other way, from an interface to a concrete type.
(In Go, arguments will be converted to the expected parameter in calls as well. That won't work well in my language since my language has overloading and that would heavily complicate overload resolution.)