[fpc-devel] type pointer to record before record.

Marco van de Voort marcov at stack.nl
Fri Apr 29 10:35:04 CEST 2011


In our previous episode, Skybuck Flying said:
> 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".

It's in all manuals and books that describe pascal pointers that I know off.
 
> Now some question about this:
> 
> 1. Is there a compiler-related technical reason why it has to be like this ? 
> If so explain shortly...

Yes, as soon as a type block closes (when whatever  next block starts), the
compiler knows that the types in the block must be completely defined. If
not he must deal with the possible incomplete state of identifiers
throughout the whole compiler, now only in the typeblock.
 
> 2. Is there perhaps a technical solution for it so this is no longer 
> required ? If so how much effort would a solution cost ?

It's like Joerg remarks about the modifiers. Things can be done, but lead to
much larger problems to solve elsewhere. It is not worth it.

That being said, the example is a more easily solved case. Since that is a
sequence of typeblocks rather than a alternation of different kind of
blocks.

Trouble is that after 42 years of pascal, cases like this can have been done
deliberate. IOW to limit forward looking and get errors earlier.

Changing this and partitioning the Pascal dialects in the ones that have it,
and the ones that have not (and most will have not) is idiotic.

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

Yes
 
> 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 ?

No. Not even the trivial repeated "TYPE" case.

Such changes create more confusion that they solve.

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

The repeated sequence of TYPE not that much, but people would rely on it,
and it might confuse people using multiple compiler and dialects (errors
suddenly happen on different moments)

As soon as you start with also allowing other blocks, then it becomes a
massive problem.



More information about the fpc-devel mailing list