3 ms·
There's a little more nuance to this. The compiler knows the static type of any value placed into an interface value, and emits code to place a concrete type po
by mknyszek 1mo ago
There's a little more nuance to this. The compiler knows the static type of any value placed into an interface value, and emits code to place a concrete type pointer (or itab pointer) into the interface value. You can see this in the disassembly.
Later when you pass this value around and assign it to places, sure, there may be a different type depending on where the interface value came from. But the construction of these values is very much static.
In this sense I wouldn't really call this "resolv[ing] while the program runs" unless you take a very broad sense of "resolution."
- masklinn 1mo agoThe construction of interface values is a very shallow mean and essentially irrelevant to the need for interfaces. Whereas the runtime resolution of operations performed through an interface (dynamic dispatch) is the primary purpose of and use care for interfaces, with the dynamic resolution of wrapped types (type erasure / downcasts / type switches) is the secondary one.