[fpc-pascal] How can I implement "thrice" in Free Pascal?

Andrew Pennebaker andrew.pennebaker at gmail.com
Wed Oct 19 10:01:05 CEST 2011


Sven, I added the {$mode delphi} macro and prefaced each type with the
"generic" specification. I'm still getting errors.

paycheck.pas:

unit Paycheck;
{$mode delphi}
interface
type
    generic TArray<T> = array of T;
    generic TFn<T> = function() : T;
...

Trace:

fpc example.pas
Compiling example.pas
Compiling paycheck.pas
paycheck.pas(5,32) Error: Identifier not found "T"
paycheck.pas(5,32) Error: Error in type definition
paycheck.pas(6,2) Error: This type can't be a generic
paycheck.pas(6,33) Error: Identifier not found "T"
paycheck.pas(7,1) Error: This type can't be a generic
paycheck.pas(7,25) Fatal: Syntax error, ";" expected but "<" found
Fatal: Compilation aborted

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Wed, Oct 19, 2011 at 2:28 AM, Sven Barth <pascaldragon at googlemail.com>wrote:

> Am 18.10.2011 23:08, schrieb Andrew Pennebaker:
>
>  Barth, something's not quite right. I've compiled and installed the
>> trunk version of fpc, but it won't recognize this syntax.
>>
>> paycheck.pas:
>>
>> unit Paycheck;
>> interface
>> type
>> TArray<T> = array of T;
>> ...
>>
>> Trace:
>>
>> fpc example.pas
>> Compiling example.pas
>> Compiling paycheck.pas
>> paycheck.pas(4,8) Fatal: Syntax error, "=" expected but "<" found
>> Fatal: Compilation aborted
>>
>> Either my syntax is wrong, or trunk doesn't have the syntax, or I'm
>> having trouble getting the trunk version.
>>
>
> You either need to add "{$mode delphi}" between "unit Paycheck;" and
> "interface" or you need to write it like this (though I haven't tested it):
>
> type
>  generic TArray<T> = array of T;
>
> Regards,
> Sven
>
> PS: It's more polite to use the first name when addressing persons in a
> mailing list.
>
>
> ______________________________**_________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.**org<fpc-pascal at lists.freepascal.org>
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111019/22724c02/attachment.html>


More information about the fpc-pascal mailing list