|
|
|
|
|
by cyco130
446 days ago
|
|
I've long entertained the idea of a language feature that allows returning unknown sized objects by value. The calling convention would generate two function calls, one to go get the size which would then be passed to alloca to reserve space for the return value and a second call to get the actual result. Not sure of all the implications but I think it might be an idea worth pursuing to make things like variable length arrays and structs with flexible members near-first class constructs in the language. Pseudocode: function zero_filled_int_array(length: usize): int[length] {
...
}
The int[length] bit determines the return value of the size call and the main body constitutes the part that actually fills in the value. |
|