Sign in Join

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

Mailing lists / fpc-pascal / 2013-11

Is Nested Procedure Types

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Andrew Brunner

I'm wondering if the is nested procedure type is supposed to work

{$modeswitch nestedprocvars}
Type TMyCallback=procedure(Index:Integer) is nested;

I thought 2.6.0 was supposed to support this but I'm using FPC from svn/trunk and it does not. Any ideas?

see also:
http://wiki.freepascal.org/FPC_New_Features_2.6.0#Support_for_nested_procedure_variables

Thanks,

Andrew Brunner Aurawin LLC 512.850.3117 https://aurawin.com/ Aurawin is a great new way to store, share and enjoy your photos, videos, music, and more.

Reply by email

Andrew Brunner
to Jonas Maebe

Ok, I had a test program that used a few other units. Apparently this had to be placed at the top of my units that used and implemented the nested callback type.

{$mode objfpc}
{$modeswitch nestedprocvars}

The last question I have is when can I expect to use nested procedure variables system wide without compiler directives? What's the hold-up or reason why the mode is even needed?

Thanks again,

Jonas Maebe wrote 15 lines
On 23 Nov 2013, at 15:47, Andrew Brunner wrote: > I'm wondering if the is nested procedure type is supposed to work > > {$modeswitch nestedprocvars} > > Type TMyCallback=procedure(Index:Integer) is nested; > > I thought 2.6.0 was supposed to support this but I'm using FPC from svn/trunk and it does not. Any ideas? It does work, see e.g. http://svn.freepascal.org/svn/fpc/trunk/tests/test/tmaclocalprocparam2d.pp Jonas_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to Andrew Brunner
Andrew Brunner wrote
Ok, I had a test program that used a few other units. Apparently this had to be placed at the top of my units that used and implemented the nested callback type. {$mode objfpc} {$modeswitch nestedprocvars}

If you turn on warnings, you'll see that the compiler tells you that global switches must appear before any statements.

The last question I have is when can I expect to use nested procedure variables system wide without compiler directives? What's the hold-up or reason why the mode is even needed?

They are only enabled by default in macpas mode and ISO because traditional Macintosh Pascal and ISO Pascal compilers are the only ones that supported them by default (albeit not via the "is nested" syntax). They'll probably never be enabled by default in any other mode. The reason is simply that there is no need to do so.

Jonas

Reply by email

Sven Barth
to Andrew Brunner: Ok, I had a test program that used a few other units. Apparently this had to be placed…
Andrew Brunner wrote
The last question I have is when can I expect to use nested procedure variables system wide without compiler directives? What's the hold-up or reason why the mode is even needed?

Same reason why advanced records are disabled by default and why also type helpers will require a modeswitch in the future (before 2.8.0 is branched): to keep the objfpc mode clean.

Regards,
Sven

Reply by email