Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-11

understanding generics

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Ishenin

Hello, FPC developers' list

I am trying to understand how to add an enumerator support to the fgl containers. Seems it is imposible.

I need enumerator to return the same type as generic container. So I declared enumerator class as generic too. But how to use it inside the generic container class?

I guessed to use the next construction:

generic TFPGList<T> = class(TFPSList)
type public

   TFPGListEnumeratorSpec   =  specialize  TFPGListEnumerator<T>;

....

Everything compiles fine, but when I declare a specialize type for the generic TFPGList I get very strange compiler errors.

I attached a simple project which exposes the bug.

My fgl patch which I tried to make work is here:
http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=18801

Best regards,
Paul Ishenin.

Reply by email

Florian Klaempfl
to Paul Ishenin
Show quoted text 21 lines
Hello, FPC developers' list I am trying to understand how to add an enumerator support to the fgl containers. Seems it is imposible. I need enumerator to return the same type as generic container. So I declared enumerator class as generic too. But how to use it inside the generic container class? I guessed to use the next construction: generic TFPGList<T> = class(TFPSList) type public TFPGListEnumeratorSpec = specialize TFPGListEnumerator<T>; .... Everything compiles fine, but when I declare a specialize type for the generic TFPGList I get very strange compiler errors. I attached a simple project which exposes the bug.

Probably something wrong with nested token replay.

Reply by email

Paul Ishenin
to Florian Klaempfl
Florian Klaempfl wrote
Probably something wrong with nested token replay.

Exactly. As I see, tscannerfile.startreplaytokens needs to be fixed. It get the new buf and does preserve/restore the old. As result new nested specialize brokes scanner.

Best regards,
Paul Ishenin.

Reply by email

Paul Ishenin
to Paul Ishenin
Paul Ishenin wrote 6 lines
Florian Klaempfl wrote: > Probably something wrong with nested token replay. > Exactly. As I see, tscannerfile.startreplaytokens needs to be fixed. It get the new buf and does preserve/restore the old. As result new nested specialize brokes scanner.

I made a patch for this:http://bugs.freepascal.org/view.php?id=15077 I don't want to apply myself since I can misunderstand something in how this supposed to work.

Please review/apply and then I can continue with my enumerator support for the generic container classes :)

Best regards,
Paul Ishenin.
<http://bugs.freepascal.org/view.php?id=15077>

Reply by email