General Category > Ideas
Fat pointer syntax support for 1D array like structs
(1/1)
shiv:
It would be nice to allow the following type of syntax:
struct S {
int len;
f32 data[];
};
struct S *s = malloc( sizeof( struct S ) + 100 * sizeof( f32 ) );
s->len = 100;
(*s)[0] = (*s)[1] + (*s)[2];
So if a struct ends with a variable length array (or just a pointer type) then the array access syntax using [] is honored.
lerno:
Ok, so a sort of syntactic sugar?
--- Code: ---// So these would be equal:
y = s->data[x];
y = (*s)[x];
--- End code ---
Correct?
shiv:
Yes!
Navigation
[0] Message Index
Go to full version