Re: [fpc-pascal] bug or feature?
> On Feb 12, 2022, at 11:40 PM, Jonas Maebe via fpc-pascal > wrote: > > I wouldn't consider this to be working by design, but rather because of > implementation limitations. I agree and it should be fixed probably. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
On Sat, 12 Feb 2022 17:58:27 +0100 Jonas Maebe via fpc-pascal wrote: >[...] > >> I wouldn't consider this to be working by design, but rather > >> because of implementation limitations. +1 pas2js complained. That's how I found out. Someone renamed a class, added an alias for compatibility, forgot to rename the implementation, and fpc did not complain. > > Why do you consider it a limitation ? > > > > Because the compiler currently has no way to distinguish the types > > when resolving the > > name "T" (as used in my example)? > > Indeed. > > > Then it is a strange coincidence that Delphi has it too :-) > > The simplest way to implement alias types is to just have them refer > to the original type... Actually pas2js did an even simpler approach here: Look up the identifier without resolving the original type ;) Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
On 12/02/2022 17:47, Michael Van Canneyt via fpc-pascal wrote: On Sat, 12 Feb 2022, Jonas Maebe via fpc-pascal wrote: On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote: PS. Just tested, the compiler accepts both... Amazing, I never thought this would be possible. I'd better update the docs :-) I wouldn't consider this to be working by design, but rather because of implementation limitations. Why do you consider it a limitation ? Because the compiler currently has no way to distinguish the types when resolving the name "T" (as used in my example)? Indeed. Then it is a strange coincidence that Delphi has it too :-) The simplest way to implement alias types is to just have them refer to the original type... Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
On Sat, 12 Feb 2022, Jonas Maebe via fpc-pascal wrote: On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote: PS. Just tested, the compiler accepts both... Amazing, I never thought this would be possible. I'd better update the docs :-) I wouldn't consider this to be working by design, but rather because of implementation limitations. Why do you consider it a limitation ? Because the compiler currently has no way to distinguish the types when resolving the name "T" (as used in my example)? Then it is a strange coincidence that Delphi has it too :-) Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote: PS. Just tested, the compiler accepts both... Amazing, I never thought this would be possible. I'd better update the docs :-) I wouldn't consider this to be working by design, but rather because of implementation limitations. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
On Sat, 12 Feb 2022, Sven Barth via fpc-pascal wrote: Michael Van Canneyt via fpc-pascal 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
Re: [fpc-pascal] bug or feature?
Michael Van Canneyt via fpc-pascal 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... Regards, Sven > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] bug or feature?
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} =-) Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] bug or feature?
Hi, This can't be right, can it? type TBird = class procedure Fly; end; TEagle = TBird; // alias procedure TEagle.Fly; begin end; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal