Re: [fpc-pascal] Two possible generics bugs

2019-12-01 Thread Ryan Joseph via fpc-pascal


> On Nov 30, 2019, at 12:58 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> This can't work. ClassType is of type TClass and TClass.Create calls 
> TObject.Create, *not* the constructor of your list type, cause the 
> constructor chain is not virtual.
> 
> What you can do is this:
> 
> === code begin ===
> 
> generic function CopyList (source: T): T;
> begin
>   result := T.Create;
>   result.Assign(source);
> end;
> 
> var
>   a, b: TNodeObjectList;
> begin
>   a := TNodeObjectList.Create;
>   b := specialize CopyList(a);
> end.
> 
> === code end ===

Found yet another internal compiler error trying your code:

https://bugs.freepascal.org/view.php?id=36388

The previous day was another internal compiler error with inline functions in 
case you missed it. ;)

https://bugs.freepascal.org/view.php?id=36381

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Two possible generics bugs

2019-12-01 Thread Ryan Joseph via fpc-pascal


> On Nov 30, 2019, at 12:58 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> This can't work. ClassType is of type TClass and TClass.Create calls 
> TObject.Create, *not* the constructor of your list type, cause the 
> constructor chain is not virtual.

Ok, so if the constructor was virtual this would work as expected? I guess that 
make sense. We really need implicit function specialization already but I don't 
want to bog down your review process anymore than I have. Removing the generic 
keyword will at least make this a little nicer to work with in the mean time 
and that's low hanging fruit.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Two possible generics bugs

2019-12-01 Thread Ryan Joseph via fpc-pascal


> On Nov 30, 2019, at 1:04 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> Well, if you want you can find any place where the _SPECIALIZE and _GENERIC 
> tokens are used and checked against mode Delphi to check against a new 
> modeswitch instead ("GENERICKEYWORDS") which must be enabled by default in 
> all modes except the Delphi ones.

So to get Delphi mode style generics in ObjFPC mode you need to disable the 
modeswitch? That's kind of backwards from what mode switches usually  do but it 
makes sense. How do you even disable a mode switch? 

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal