[fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Ryan Joseph
Is there anyway to get callbacks to work as nested functions? I get crashes when I try this and I assume it’s because the the compiler is replacing the first parameter with another value. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pa

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Sven Barth via fpc-pascal
Am 23.10.2017 11:49 schrieb "Ryan Joseph" : Is there anyway to get callbacks to work as nested functions? I get crashes when I try this and I assume it’s because the the compiler is replacing the first parameter with another value. What exactly are you trying? If the nested function accesses its

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Ryan Joseph
> On Oct 23, 2017, at 4:56 PM, Sven Barth via fpc-pascal > wrote: > > What exactly are you trying? If the nested function accesses its outer scope > then it definitely won't work. For that you'd need to wait for anonymous > function support (which are planned - at least a far as I'm concerne

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Michael Van Canneyt
On Mon, 23 Oct 2017, Ryan Joseph wrote: On Oct 23, 2017, at 4:56 PM, Sven Barth via fpc-pascal wrote: What exactly are you trying? If the nested function accesses its outer scope then it definitely won't work. For that you'd need to wait for anonymous function support (which are planned

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Mattias Gaertner
On Mon, 23 Oct 2017 20:04:36 +0700 Ryan Joseph wrote: > > On Oct 23, 2017, at 4:56 PM, Sven Barth via fpc-pascal > > wrote: > > > > What exactly are you trying? If the nested function accesses its outer > > scope then it definitely won't work. For that you'd need to wait for > > anonymous fu

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Ryan Joseph
> On Oct 23, 2017, at 8:55 PM, Mattias Gaertner > wrote: > > program test1; > > {$mode objfpc}{$H+} > {$ModeSwitch nestedprocvars} > > type > TCallback = procedure (a: integer) is nested; > > procedure DoCallback; > procedure DoThis(a: integer); > begin >writeln(a); > end; > var >

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Michael Van Canneyt
On Mon, 23 Oct 2017, Ryan Joseph wrote: On Oct 23, 2017, at 8:55 PM, Mattias Gaertner wrote: program test1; {$mode objfpc}{$H+} {$ModeSwitch nestedprocvars} type TCallback = procedure (a: integer) is nested; procedure DoCallback; procedure DoThis(a: integer); begin writeln(a); e

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Ryan Joseph
> On Oct 23, 2017, at 9:05 PM, Michael Van Canneyt > wrote: > > It is not the default because neither Delphi nor TP allow this. then that begs the question, why not? :) If local functions are a useful feature then local callbacks should be too. Regards, Ryan Joseph

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread Michael Van Canneyt
On Mon, 23 Oct 2017, Ryan Joseph wrote: On Oct 23, 2017, at 9:05 PM, Michael Van Canneyt wrote: It is not the default because neither Delphi nor TP allow this. then that begs the question, why not? :) If local functions are a useful feature then local callbacks should be too. Well, w

Re: [fpc-pascal] Callbacks as nested functions

2017-10-23 Thread LacaK
Btw there is long-time open ... may be related bug https://bugs.freepascal.org/view.php?id=18702 L. Dňa 23.10.2017 o 16:42 Michael Van Canneyt napísal(a): On Mon, 23 Oct 2017, Ryan Joseph wrote: On Oct 23, 2017, at 9:05 PM, Michael Van Canneyt wrote: It is not the default because n

Re: [fpc-pascal] Callbacks as nested functions

2017-10-28 Thread Adriaan van Os
Ryan Joseph wrote: On Oct 23, 2017, at 9:05 PM, Michael Van Canneyt wrote: It is not the default because neither Delphi nor TP allow this. then that begs the question, why not? :) If local functions are a useful feature then local callbacks should be too. Because 1. it takes a few extra