Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Sven Barth via fpc-pascal
Michael Van Canneyt schrieb am Mo., 20. Juni 2022, 08:04: > > > On Mon, 20 Jun 2022, Sven Barth via fpc-pascal wrote: > > > Am 20.06.2022 um 03:37 schrieb Hairy Pixels: > >> > >>> On Jun 19, 2022, at 10:04 PM, Sven Barth > > > wrote: > >>> > >>> As you can see the allocation only happens once an

Re: [fpc-pascal] Calling undefined function pointers in generics

2022-06-20 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Mo., 20. Juni 2022, 03:38: > NOTE: I’m replying to this and CC’ing Sven so hopefully he can see it. > > > On Jun 19, 2022, at 10:05 AM, Hairy Pixels wrote: > > > > This code snippet will give a compiler error "Syntax error, ";" expected > but "(“ found”. It’s an unspecial

Re: [fpc-pascal] Calling undefined function pointers in generics

2022-06-20 Thread Hairy Pixels via fpc-pascal
> On Jun 20, 2022, at 7:12 PM, Sven Barth wrote: > > Please report a bug. > Done. https://gitlab.com/freepascal.org/fpc/source/-/issues/39794. I may actually try to fix this myself since I may know what the problem is. And on that note did you notice I made a PR for your idea of a generic

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Michael Van Canneyt via fpc-pascal
On Mon, 20 Jun 2022, Sven Barth wrote: Michael Van Canneyt schrieb am Mo., 20. Juni 2022, 08:04: On Mon, 20 Jun 2022, Sven Barth via fpc-pascal wrote: Am 20.06.2022 um 03:37 schrieb Hairy Pixels: On Jun 19, 2022, at 10:04 PM, Sven Barth wrote: As you can see the allocation only

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Hairy Pixels via fpc-pascal
> On Jun 20, 2022, at 12:44 PM, Sven Barth wrote: > > If the compiler can proove that the function reference never leaves the scope > (that means no assignment to global variables, out/var parameters, the Result > variable, passing on to some other function or conversion to pointer (and I'm

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Hairy Pixels via fpc-pascal
Can anyone explain why this works? TProc is a normal function pointer so how did it capture gVar? My understanding is that only nested proc vars could do this. {$mode objfpc} {$modeswitch anonymousfunctions} program anonymous_functions; type TProc = procedure; procedure Call(proc: TProc); b

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Michael Van Canneyt via fpc-pascal
On Mon, 20 Jun 2022, Hairy Pixels via fpc-pascal wrote: On Jun 20, 2022, at 12:44 PM, Sven Barth wrote: If the compiler can proove that the function reference never leaves the scope (that means no assignment to global variables, out/var parameters, the Result variable, passing on to som

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Hairy Pixels via fpc-pascal
> On Jun 20, 2022, at 8:30 PM, Michael Van Canneyt via fpc-pascal > wrote: > > My point is that if someone creates an API where he/she uses "reference to > procedure" then the consumer of the API is stuck with the creation of an > interface. > > So it's not always a choice whether an interf

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Hairy Pixels via fpc-pascal
> On Jun 20, 2022, at 8:39 PM, Michael Van Canneyt via fpc-pascal > wrote: > > It allows you to run callbacks without having to declare variables globally: > > Function DoSomething : String; > > var > L : TStringList; > > begin > L:=TstringList.Create; > SomeCallBack(procedure(s : string) >

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Mo., 20. Juni 2022, 15:32: > Can anyone explain why this works? TProc is a normal function pointer so > how did it capture gVar? My understanding is that only nested proc vars > could do this. > Globals don't need to be captured, because they're reachable from any scope.

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Mo., 20. Juni 2022, 15:30: > > > > On Jun 20, 2022, at 12:44 PM, Sven Barth > wrote: > > > > If the compiler can proove that the function reference never leaves the > scope (that means no assignment to global variables, out/var parameters, > the Result variable, passing o

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Sven Barth via fpc-pascal
Michael Van Canneyt via fpc-pascal schrieb am Mo., 20. Juni 2022, 15:41: > > > On Mon, 20 Jun 2022, Sven Barth wrote: > > > Michael Van Canneyt schrieb am Mo., 20. Juni > 2022, > > 08:04: > > > >> > >> > >> On Mon, 20 Jun 2022, Sven Barth via fpc-pascal wrote: > >> > >>> Am 20.06.2022 um 03:37 s

Re: [fpc-pascal] Calling undefined function pointers in generics

2022-06-20 Thread Sven Barth via fpc-pascal
Hairy Pixels schrieb am Mo., 20. Juni 2022, 15:12: > > > > On Jun 20, 2022, at 7:12 PM, Sven Barth > wrote: > > > > Please report a bug. > > > > Done. https://gitlab.com/freepascal.org/fpc/source/-/issues/39794. I may > actually try to fix this myself since I may know what the problem is. > > An

Re: [fpc-pascal] Are there any drawbacks to "reference to"?

2022-06-20 Thread Mattias Gaertner via fpc-pascal
On Mon, 20 Jun 2022 20:32:44 +0700 Hairy Pixels via fpc-pascal wrote: > Can anyone explain why this works? TProc is a normal function pointer > so how did it capture gVar? gVar is global. No need to capture it. Only stack vars needs capture. Mattias _

[fpc-pascal] Cross-compiler for ARM64 on Windows available?

2022-06-20 Thread Wolfgang Hubert via fpc-pascal
Hi, I have developed a DLL for x64 Windows and compiled with fpc 3.2.2. I would like to compile the same code for ARM64 running Windows. I need this to support the MS Surface devices. Even though the platform list of the Lazarus Wiki https://wiki.freepascal.org/Platform_list lists "Wind

Re: [fpc-pascal] Cross-compiler for ARM64 on Windows available?

2022-06-20 Thread Sven Barth via fpc-pascal
Am 20.06.2022 um 12:34 schrieb Wolfgang Hubert via fpc-pascal: Hi, I have developed a DLL for x64 Windows and compiled with fpc 3.2.2. I would like to compile the same code for ARM64 running Windows. I need this to support the MS Surface devices. Even though the platform list of the Laza

Re: [fpc-pascal] Cross-compiler for ARM64 on Windows available?

2022-06-20 Thread Pierre Muller via fpc-pascal
Le 20/06/2022 à 23:53, Sven Barth via fpc-pascal a écrit : Am 20.06.2022 um 12:34 schrieb Wolfgang Hubert via fpc-pascal: Hi, I have developed a DLL for x64 Windows and compiled with fpc 3.2.2. I would like to compile the same code for ARM64 running Windows. I need this to support the MS Su