#NULL wrote:I guess the support Mistrel wants is to be able to rely on this, i.e. it being documented (PBs equivalent to a specification).
Correct. But I'm also asking for better support with regards to SizeOf().
#NULL wrote:I wonder if the use case of taking and using the pointer to an array is supported in the first place? The array might move in memory on a redim?
I'm not sure. This was just an example. And even if it was a block of memory created with AllocateMemory(), unless it's a pointer to a pointer then the address would still change. The current implementation is expected but I believe it is undocumented as well.
Josh wrote:With [0] you create an static array with 0 elements !!!!!!
I think Josh is right on this and I'm misunderstanding this. Field[0] is a
static array; that is, it's a pointer to the first element in a contiguous block of memory for which is defined as having 0 elements. This is probably why [1] was the preferred way in C and C99 adopted '[]' instead. 0 elements is literally 0 elements.
I think this comes down to what the definition is for the ambiguous statement of a "pointer to an array". It could be a pointer that points to the first element of an array or a pointer which is the first element itself. Hhmm...
In this case, '[0]' is a "pointer to the first element of an array". Alternatively, we can only point to a structure whose member is the first element of an array; essentially a pointer to a structure whose member can be accessed as an array.
PureBasic has a lot in common with C but some things which may seem analogous are not.
This was pulled from a Wikipedia entry on sizeof() from C but is a pretty good summary:
sizeof can only be applied to "completely" defined types. With arrays, this means that the dimensions of the array must be present in its declaration, and that the type of the elements must be completely defined. For structs and unions, this means that there must be a member list of completely defined types.