Recent

Author Topic: How to keep protected procedures accessible in derived classes  (Read 9231 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to keep protected procedures accessible in derived classes
« Reply #15 on: February 20, 2017, 07:43:22 am »
Quote
Why cant't the compile stop when it detects a circular unit reference

It can. A circular reference throws a warning. Warnings can be treated as errors: compile with -Sew and the compiler stops.

Note that I already explained that the type of circular references you refer to is always solvable with a little effort. Provide us with a little example project that fails to compile and I will solve it. If I create one that I *think* is what you mean I might otherwise be on the wrong track,,,
Quote
and handle things like forward declarations?
It is lacking information at that point. The warning is to give feedback to the programmer that he/she may have to perform further actions. As far as the compiler is concerned, the behavior is undefined.
The compiler says, "Oh, you notified me (e.g. by a forward declaration) that YOU will resolve this later by providing me with the complete information I need. Be careful, I will continue, but it is YOUR fault if something goes wrong later on....".
The compiler can't second guess you and certainly not add missing code by inserting forward declarations itself.
Would be a DWIM compiler: highly desirable, but Utopia. Circular reference is literary chicken and egg.

Note that even a multi-pass compiler can not solve this issue logically without programmer intervention with language constructs like forward declarations when there are conflicts. Although I am quite sure I have to respond to some nitwits that want proof of that or "know better".

Just write an example project. It does not have to do anything, but show us WHERE you still have issues. I can solve it quickly, but put in some effort.
« Last Edit: February 20, 2017, 09:18:00 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to keep protected procedures accessible in derived classes
« Reply #16 on: February 20, 2017, 09:43:15 am »
It's always the same: I have two independant classes in different units and the classes
should have a reference to each other or have functions or procedures with the other class as parameter or function result.

Edit: These references are pointers internaly, so the compiler just has to check the type in the interface part. Nothing else.
« Last Edit: February 20, 2017, 09:46:14 am by Pascal »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to keep protected procedures accessible in derived classes
« Reply #17 on: February 20, 2017, 09:51:06 am »
Quote
Why cant't the compile stop when it detects a circular unit reference

It can. A circular reference throws a warning. Warnings can be treated as errors: compile with -Sew and the compiler stops.

With stop i mean stop building it's internal list of used units and continue withe the next unit in the uses clause.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to keep protected procedures accessible in derived classes
« Reply #18 on: February 20, 2017, 12:12:35 pm »
Pascal, please provide me with a simple example that I can feed to the dog and makes the dog bark? (The compiler). I can fix it...
I haven't seen a complete project yet. Simple,somewhat compilable start that fails.
I need that to prevent I make wrong assumptions.

I can show you TODAY if you do that. Many of us can do so.

BTW: The compiler doesn't build an internal list, but an internal tree. See the problem? Leafs on the tree can be miles apart.
« Last Edit: February 20, 2017, 12:18:40 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018