I've been using this for so long that I forgot about it. A colleague coming from C# asked how you can declare a pointer to a type that you haven't defined as yet.
I've been using this for so long that I forgot about it. A colleague coming from C# asked how you can declare a pointer to a type that you haven't defined as yet.
Like
Type
TMyPtr = ^TMyRecord;
TMyRecord = Record
MyField : integer;
end;
I just told him Pascal magic, because in some other cases you may need a "forward" statement, but not with pointers. Does anyone know the history behind why this was done? I mean, you COUL define the TMYRecord record type before you declare the TMyPtr;
Like
Type
TMyPtr = ^TMyRecord;
TMyRecord = Record
MyField : integer;
end;
I just told him Pascal magic, because in some other cases you may need a "forward" statement, but not with pointers. Does anyone know the history behind why this was done? I mean, you COUL define the TMYRecord record type before you declare the TMyPtr;
Funny that a C# developer asks this
ReplyDeleteNothing to write home about here. Only if the type uses that pointer type does it get interesting.
ReplyDeleteToday, this is legal
ReplyDeleteTRec = record
Next: ^TRec;
end;
as is
TRec = record
type
PRec = ^TRec;
var
Next: PRec;
end;