[fpc-pascal] specialize, identifier not found

Sven Barth pascaldragon at googlemail.com
Wed Dec 16 21:01:15 CET 2015


On 16.12.2015 17:57, Santiago A. wrote:
> El 16/12/2015 a las 17:25, Sven Barth escribió:
>>
>> Am 16.12.2015 16:12 schrieb "Santiago A."
>> <<mailto:svaa at ciberpiula.net>svaa at ciberpiula.net>:
>> >
>> > Type
>> >  TRegAlias=record
>> >        AliasName:string
>> >     ...
>> >  end;
>> >
>> >  TArrayAlias=specialize TArray<TRegAlias>; // <==== Error here
>> >
>> > defconexion.pas(71,14) Error: Identifier not found "specialize"
>> > defconexion.pas(71,25) Error: Error in type definition
>> > defconexion.pas(71,25) Fatal: Syntax error, ";" expected but "identifier
>> > TARRAY" found
>> >
>> >
>> > Why this error?
>> > Why does the compiler try to look for a Identifier "specialize" instead
>> > of interpreting it as a reserved word?
>>
>> Which FPC version? Which language mode?
>>
> {$mode Delphi}
>
> I've just tried {$mode objfpc} and compiles type declaration, (Delphi
> mode can't understand generics?)

Mode Delphi follows Delphi's syntax, thus no "generic" and "specialize" 
keywords.

>
> But now I have another problem, when I use the variable, I get "Argument
> can't be assigned to"
>
> var
> arrayAlias:TArrayAlias;
>    aliasList:TStringList;
>    ...
> begin
> ...
>    arrayAlias[i].AliasName:=aliasList[i]; //<==== Error here
>
> Where TArrayAlias=TArray<TRegAlias>, and TArray<_T> is an object, not a
> class.
> And it has a property
>
>        property item[index:Integer]:_T read getItem write setItem; default;
>
> So, it has the getter and the setter.
>
> Doesn't objfpc mode accept default indexed properties?

The problem isn't default indexed properties. I guess your TRegAlias is 
a record, thus it will be victim of this: 
http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields

Regards,
Sven



More information about the fpc-pascal mailing list