Code: Select all
Structure Triangle
*POINT.POINT[3]
EndStructure
Code: Select all
Structure Triangle
*POINT.POINT[3]
EndStructure
Code: Select all
Structure POINT_3
POINT.Point[3]
EndStructure
Structure Triangle2
*POINT.POINT_3
EndStructure
Debug SizeOf (Triangle2\POINT)
Define Triangle2.Triangle2
Triangle2\POINT=AllocateStructure(POINT_3)
Triangle2\POINT\POINT[0]\x=$1
Triangle2\POINT\POINT[0]\y=$2
Triangle2\POINT\POINT[1]\x=$11
Triangle2\POINT\POINT[1]\y=$12
Triangle2\POINT\POINT[2]\x=$21
Triangle2\POINT\POINT[2]\y=$22
ShowMemoryViewer(Triangle2\Point, 50)
CallDebugger
I understand this. What I'm saying is that the syntax suggest for Field.Type that the array portion belongs to the type and it's confusing. There is a big difference between and array of pointers and a pointer to an array.Josh wrote:The compiler recognizes this as no different than *POINT[3] because it is no different. A pointer is a pointer, no matter if a structure is assigned to it or not.
Code: Select all
Structure Triangle
*Point.PointXY[3]
Size.l
EndStructure
Structure Rectangle
*Point.PointXY[4]
Size.l
EndStructure
Structure Pentagon
*Point.PointXY[5]
Size.l
EndStructure
Code: Select all
Structure PolygonXY
*Point.PointXY[0]
Size.l
EndStructure
There is no such thing as a pointer to an array. There is only an unstructured pointer to an address or a structured pointer to a defined stucture.Mistrel wrote:I understand this. What I'm saying is that the syntax suggest for Field.Type that the array portion belongs to the type and it's confusing. There is a big difference between and array of pointers and a pointer to an array.Josh wrote:The compiler recognizes this as no different than *POINT[3] because it is no different. A pointer is a pointer, no matter if a structure is assigned to it or not.
Of course there is.Demivec wrote:There is no such thing as a pointer to an array.
Code: Select all
Structure IntegerArray
ToArray.i[0]
EndStructure
Dim AnArray(10)
For i=0 To 10-1
AnArray(i)=i+1
Next i
Define *Pointer.IntegerArray=@AnArray()
For i=0 To 10-1
Debug *Pointer\ToArray[i]
Next
You've only shown a structured pointer as I specified.Mistrel wrote:Of course there is.Demivec wrote:There is no such thing as a pointer to an array.
Code: Select all
Structure IntegerArray ToArray.i[0] EndStructure Dim AnArray(10) For i=0 To 10-1 AnArray(i)=i+1 Next i Define *Pointer.IntegerArray=@AnArray() For i=0 To 10-1 Debug *Pointer\ToArray[i] Next
Demivec wrote:There is no such thing as a pointer to an array. There is only an unstructured pointer to an address or a structured pointer to a defined stucture.
If you want a pointer to an array then you have to define a structure that contains an array.
Code: Select all
Structure _ARRAY_OF_POINTS_XY
PointXY.i[0]
_padding.i[1]
EndStructure
CompilerIf #False
Structure ARRAY_OF_POINTS_XY
PointXY.i[0]
EndStructure
Structure ARRAY_OF_POINTS_XY Extends ARRAY_OF_POINTS_XY
EndStructure
CompilerEndIf
Macro ARRAY_OF_POINTS_XY
_ARRAY_OF_POINTS_XY
EndMacro
;/ 4
Debug SizeOf(ARRAY_OF_POINTS_XY)
I would say the term 'pointer to an array' is a matter of definition. In my opinion the pointer to the first element of an array could be seen as 'pointer to an array'.Demivec wrote:There is no such thing as a pointer to an array.
I agree with you at least in regard to definitions.Josh wrote:I would say the term 'pointer to an array' is a matter of definition. In my opinion the pointer to the first element of an array could be seen as 'pointer to an array'.Demivec wrote:There is no such thing as a pointer to an array.