C23 is cancelled due to missing the publication deadline
iso.org7 pointsby ainar-g4 comments
v := interfaceType(concreteTypeValue)
in Go, what you're actually doing on a lower level is: dataPtr := &concreteTypeValue
typePtr := typeData[concreteType]()
v := interfaceData{
data: dataPtr,
typ: typePtr,
}
The first line here is the allocation, since (at least, the way I recall the rule) in Go pointers never point to values on the stack, so concreteTypeValue must be allocated on the heap. The rule about pointers not pointing to the stack is there to make it easier for goroutine stacks to grow dynamically. TYPE
TWeekday = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday);
VAR
WeekdayNameIndex : ARRAY [TWeekday] OF ShortString = ('Mon', 'Tue',
'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
Now `WeekdayNameIndex` is a properly type- and range-checked look-up table.