Hi Mike,
On 25 May 2018, at 11:50, Mike Pall <mikelj-1805@xxxxxxx> wrote:
Konstantin Stefanov wrote:
[...] This will not break exisitng semantics [...]
No, it _would_ break semantics, because the remaining arguments to
ffi.new() are considered initializers. Silently adding a VLA nelem
parameter for the 'a[]' case would change the interpretation of
the ffi.new() arguments.
As you've shown, in C you have to go through some contortions to
allocate a struct with a pseudo-VLA 'a[]'. You can certainly call
malloc() from the FFI, too. If you want that, then go for it.
The true VLA syntax 'a[?]' is an FFI extension for more comfort.
It's incompatible in many ways. sizeof() is just the most visible
difference.
You seem to be complaining that you want raw C declarations, but
the comfort of the FFI extension. Pick one.
The distinction between 'a[]' and 'a[?]' has been given a lot of
thought in the design phase of the FFI. It's intentional and it
will stay.