Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

type pointer to record before record.

86 views
Skip to first unread message

Skybuck Flying

unread,
Apr 28, 2011, 2:56:57 PM4/28/11
to
Hello,

In free pascal/pascal/delphi it's necessary to declare a pointer to a
record, which is to be used inside the record to point to itself, before the
record itself without a type directive in between them for example:

// correct:
type
PMyRecord = ^TMyRecord;
TMyRecord = record
mSelf : PMyRecord;
mNext : PMyRecord;
end;

// incorrect/not allowed:
type
PMyRecord = ^TMyRecord; // above type anywhere else.

type
TMyRecord = record
mSelf : PMyRecord;
mNext : PMyRecord;
mPrev : ^TMyRecord; // not allowed.
end;

PMyRecord = ^TMyRecord; // below anywhere else

// and so forth...

I would first like to remark about this: "This is very newb unfriendly...
newbs might not know this... and will get frustrated by this
weird/odd/non-intuitive language construction".

Now some question about this:

1. Is there a compiler-related technical reason why it has to be like this ?
If so explain shortly...

2. Is there perhaps a technical solution for it so this is no longer
required ? If so how much effort would a solution cost ?

3. (Does free pascal still follow these restrictions ? I guess so... )

Final question assuming it's solvable::

4. Do you think it's worth to solve this oddity and make the language more
newb friendly and more intuitive ?

5. Would it break anything ? (I think not... it would be an
extension/relaxation of the language...)

Bye,
Skybuck.


spacetime

unread,
May 28, 2011, 4:35:27 PM5/28/11
to
On Apr 28, 8:56 pm, "Skybuck Flying" <IntoTheFut...@hotmail.com>
wrote:


1. This is how it works under Turbo Pascal:
During type declaration block processing Turbo Pascal stores pointer
types to temporary symbol table.
After the type declaration block has been processed it resolves
pointer references to types.

check
http://turbopascal.org/processing-type-declarations
http://turbopascal.org/processing-non-object-types

2. Well, it would be possible but I see no need for this.

3. Yes

4. No

5. I don't support this way of language relaxation....

Igor

0 new messages