[fpc-pascal] Restricted generic param types
    Sven Barth 
    pascaldragon at googlemail.com
       
    Fri Nov  9 07:53:39 CET 2018
    
    
  
Am Fr., 9. Nov. 2018, 05:48 hat Ryan Joseph <ryan at thealchemistguild.com>
geschrieben:
> I’m getting a parse error here. It thinks the “U” is another type but in
> fact it’s another generic parameter and not related to “T” at all.  Is this
> a bug? I don’t think the way the parsing works the compiler actually can
> discern this condition.
>
> {$mode objfpc}
> {$modeswitch advancedrecords}
>
> program generic_constants_restricted;
>
> type
>         generic TList<T:tobject, U> = record
>         end;
>
> begin
> end.
>
You must use ";" in that case. All parameters separated by "," are of the
same "constraint type" while ";" separates these. Essentially like a
parameter declaration for a function.
(and yes, Delphi handles it like that as well)
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181109/30de750c/attachment.html>
    
    
More information about the fpc-pascal
mailing list