On Sat, 12 Feb 2022, Sven Barth via fpc-pascal wrote:

Michael Van Canneyt via fpc-pascal <fpc-pascal@lists.freepascal.org>
schrieb am Sa., 12. Feb. 2022, 12:14:



On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:

Hi,

This can't be right, can it?

type
 TBird = class
   procedure Fly;
 end;
 TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;

Personally, I would not allow this.
But Delphi compiles and runs it...

Maybe something to check for {$mode objfpc} =-)


The compiler does not have any real tracking for non-type aliases... As far
as the compiler is concerned these are interchangeable...

I think Mattias just got some more gray hairs :-)

So if I understand this correctly, I can do

---
Interface

Type
  TSomeReallyAnnoyingIncrediblyLongClassName = Class
    Procedure DoSomething;
  end;

implementation

Type
  T1 = TSomeReallyAnnoyingUltraLongClassName;

procedure T1.DoSomething;

begin
end;
---

And consequently also

---
Interface

Type
  TSomeReallyAnnoyingIncrediblyLongClassName = Class
  Type
     TSomeReallyAnnoyingSubClass = class
        Procedure DoSomething;
     end;
  end;

implementation

Type
  T1 = TSomeReallyAnnoyingIncrediblyLongClassName.TSomeReallyAnnoyingSubClass;

procedure T1.DoSomething;

begin
end;
---

The lazarus code tools maintainer will have a field day with this one ;-)

Michael.

PS. Just tested, the compiler accepts both... Amazing, I never thought this
would be possible. I'd better update the docs :-)
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to