Sign in Join

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

Mailing lists / fpc-pascal / 2018-12

Generics question

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

{ TFoo }

  generic TFoo<T> = class
    procedure Bar;
  end;

{ TFoo }

procedure TFoo.Bar;
  procedure localproc;
  begin end;
begin
end;
This will not compile (fpc 3.0.4):
gentest.lpr(35,4) Error: Generic methods cannot have nested procedures

While the message is clear, the reason for this is not (to me at last).

Does anybody know why?

Bart

Bart

Reply by email

Sven Barth
to Bart

Am So., 2. Dez. 2018, 23:29 hat Bart geschrieben:

Show quoted text 23 lines
Hi, { TFoo } generic TFoo<T> = class procedure Bar; end; { TFoo } procedure TFoo.Bar; procedure localproc; begin end; begin end; This will not compile (fpc 3.0.4): gentest.lpr(35,4) Error: Generic methods cannot have nested procedures While the message is clear, the reason for this is not (to me at last). Does anybody know why?

Because Delphi does not allow that either. We relaxed that however in 3.1.1 and it should be part of 3.2.0. You can test the corresponding branch of you want.

Regards,
Sven

Reply by email

Martok
to Sven Barth
Sven Barth wrote
Because Delphi does not allow that either. We relaxed that however in 3.1.1 and it should be part of 3.2.0. You can test the corresponding branch of you want.

Is this related to <https://bugs.freepascal.org/view.php?id=33013> ? The example I provided then doesn't crash anymore, but it sounds like that is the sort of code that would not be accepted at all in Delphi?

I'll have to check the real-world code again, might be able to close this bug as "fixed in the mean time".

Regards, Martok Ceterum censeo b32079 esse sanandam.

Reply by email

Sven Barth
to Martok

Am Mo., 3. Dez. 2018, 10:53 hat Martok
geschrieben:

Show quoted text 15 lines
Am 03.12.2018 um 08:00 schrieb Sven Barth via fpc-pascal: > Because Delphi does not allow that either. We relaxed that however in 3.1.1 and > it should be part of 3.2.0. You can test the corresponding branch of you want. Is this related to <https://bugs.freepascal.org/view.php?id=33013> ? The example I provided then doesn't crash anymore, but it sounds like that is the sort of code that would not be accepted at all in Delphi? I'll have to check the real-world code again, might be able to close this bug as "fixed in the mean time".

Yes, I fixed something related to nested procs some weeks ago and yes, Delphi does not support that (and some other things we support, but they don't :D ).

Regards,
Sven

Reply by email