I have many situations where i would like to make cyclic references in types without the need to use pointer and type aliases. Wouldn't it be possible to make byref fields in types which hide the pointers to objects. Why is there even a type alias needed there? You could just assume if you have a non standard data type and it's a pointer (or reference) to a new symbolname it has to be the name of a not yet defined type or class. Because the size of that field is known at this point you can just define the type.
Am i right assuming that this code with types and pointers should be theoratically possible to compile by a one pass compiler?
Code: Select all
Type Person
firstname As String
lastname As String
birthdate As Integer
End Type
Type Parent extends Person
childs(Any) As Child Ptr
End Type
Type Child extends Person
father As Parent Ptr
mother As Parent Ptr
End Type
Maybe there could be byref in types to hide pointers
Code: Select all
Type Parent extends Person
childs(Any) ByRef As Child
End Type
Type Child extends Person
father ByRef As Parent
mother ByRef As Parent
End Type
To make it even shorter you could assume for classes that all fields of a class are just references to the the instance of an object.
So you could even omit byref keyword in classes.
Code: Select all
Class Parent extends Person
childs(Any) As Child
End Type
Class Child extends Person
father As Parent
mother As Parent
End Class