[fpc-pascal] Correct way to write generic type aliases

2016-08-28 Thread leledumbo
I want my in-project units depend on a single in-project unit which abstracts
the actual used out-project units. i.e. instead of:

MyUnit1 -> RTLUnit
MyUnit2 -> RTLUnit

I want it to be:

MyUnit1 -> RTLAbstractorUnit
MyUnit2 -> RTLAbstractorUnit
RTLAbstractorUnit -> RTLUnit

So I try to write:

unit DataStructures;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Generics.Collections;

type

  // Error: Identifier not found "TObjectList"
  TMyList = TObjectList;

  // Error: Identifier not found "T"
  generic TMyList = specialize TObjectList;
  generic TMyList = specialize TObjectList;

  // Unhandled EAccessViolation followed by Error: Compilation raised
exception internally
  generic TMyList = class(specialize TObjectList); 
  generic TMyList = class(specialize TObjectList); 
  generic TMyList = class(specialize TObjectList) end; 

implementation

end.

but neither of above seems to work. What is the correct way to write generic
type aliases? Even if it's not real alias like the last 3, as long as it's
working, I'm OK.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Correct-way-to-write-generic-type-aliases-tp5726179.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Correct way to write generic type aliases

2016-08-28 Thread Sven Barth
Am 28.08.2016 21:15 schrieb "leledumbo" :
>
> but neither of above seems to work. What is the correct way to write
generic
> type aliases? Even if it's not real alias like the last 3, as long as it's
> working, I'm OK.

Type aliases for generics are not supported.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Correct way to write generic type aliases

2016-08-28 Thread leledumbo
> Type aliases for generics are not supported.

OK, but Delphi seems to support the last 3 variant which creates a generic
subclass of a specialized generic type:
http://stackoverflow.com/questions/10060009/is-it-possible-to-create-a-type-alias-to-a-generic-class-in-delphi
At least, it shouldn't make the compiler raise EAccessViolation, right? ;)




--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Correct-way-to-write-generic-type-aliases-tp5726179p5726181.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Correct way to write generic type aliases

2016-08-28 Thread Sven Barth
Am 29.08.2016 05:36 schrieb "leledumbo" :
>
> > Type aliases for generics are not supported.
>
> OK, but Delphi seems to support the last 3 variant which creates a generic
> subclass of a specialized generic type:
>
http://stackoverflow.com/questions/10060009/is-it-possible-to-create-a-type-alias-to-a-generic-class-in-delphi
> At least, it shouldn't make the compiler raise EAccessViolation, right? ;)

Remind me not to jump over code examples... Yes, the last three should
work. Would you please report a bug?

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal