On 08/28/2013 08:01 PM, Andrew Lutomirski wrote:
> On Wed, Aug 28, 2013 at 10:52 AM, Kenton Varda <
temp...@gmail.com> wrote:
>> I am thinking that the syntax for declaring an inline list would be like so:
>>
>> struct Foo {
>> bar[4] @0 :Int32; # list of four Int32s
>> }
>>
>> [...]
>>
>> What do people think?
Suits me, especially the possible gain in representational compactness.
For default values, one could use the same syntax as for non-inline lists.
It is also close to being extendable in a backward-compatible fashion:
increasing the list size would be possible, if one could put a version
number for the time of the increase somewhere. Like
struct Foo {
bar [4]@0, [8]@2, [12]@3 :Int8; # list of four, later eight and
foo @1 : Bool; # finally twelve bytes
}
Only that this looks quite ugly and thus should not be done until it is
_really_ necessary.
> I can't actually think of anything wrong with it other than the
> awkward code you'll generate when you try to copy the thing to a flat
> array.
The code should be equivalent to a completely unrolled loop with the
offsets encoded as immediates. Given that the (/my) use case is
relatively small lists (<= 8 elements) this is probably optimal. For
lists of types smaller than 64b reads of adjacent values might even be
coalesced.
Jan