Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Ryan Joseph via fpc-pascal
> On Aug 21, 2021, at 3:09 PM, Michael Van Canneyt via fpc-pascal > wrote: > > As in Delphi 'reference to' will also be used for all references where an > anonymous functon can be used. But you can perfectly use methods and local > functions for that. So it will function a like a catch-all

Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Michael Van Canneyt via fpc-pascal
On Sat, 21 Aug 2021, Ryan Joseph via fpc-pascal wrote: On Aug 21, 2021, at 1:30 PM, Michael Van Canneyt wrote: "Reference to" can be used for the others as well. How do you mean? Reference to is currently only available for cblocks on macOS I think so I'm not sure how this would

Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Ryan Joseph via fpc-pascal
> On Aug 21, 2021, at 1:30 PM, Michael Van Canneyt > wrote: > > "Reference to" can be used for the others as well. How do you mean? Reference to is currently only available for cblocks on macOS I think so I'm not sure how this would look. Regards, Ryan Joseph

Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Michael Van Canneyt via fpc-pascal
On Sat, 21 Aug 2021, Ryan Joseph via fpc-pascal wrote: On Aug 21, 2021, at 12:08 PM, Jonas Maebe via fpc-pascal wrote: You can pass global functions to "is nested" procvars, so at least these two don't need to be separate. OTOH, there's another type: cblocks :) So up to 4 types are

Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Ryan Joseph via fpc-pascal
> On Aug 21, 2021, at 12:08 PM, Jonas Maebe via fpc-pascal > wrote: > > You can pass global functions to "is nested" procvars, so at least these > two don't need to be separate. > > OTOH, there's another type: cblocks :) So up to 4 types are needed: "is nested", "of object" and "reference

Re: [fpc-pascal] Better way to handle callback types

2021-08-21 Thread Jonas Maebe via fpc-pascal
On 21/08/2021 20:06, Ryan Joseph via fpc-pascal wrote: > type > generic TSList = class > type > TComparator = record > private type > TFuncProc = function (constref left, right: T; context: pointer): > integer; > TFuncNested = function (constref left, right:

[fpc-pascal] Better way to handle callback types

2021-08-21 Thread Ryan Joseph via fpc-pascal
FPC has a number of function pointer types and eventually will have another in "reference to" closures. This presents a problem of how the programmer can make a function that is type agnostic so that we can use different types of callbacks. Currently this is the best solution I can think of