Re: [fpc-pascal] Freeing memory with exceptions

2023-05-30 Thread Sven Barth via fpc-pascal
Steve Litt via fpc-pascal schrieb am Di., 30. Mai 2023, 21:57: > I don't know about other operating systems, but on Linux a crashed > program gives up all its memory, even leaked memory, upon termination, > so I'm not sure why this attention to memory leak on abnormal > termination is even

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-30 Thread Steve Litt via fpc-pascal
Michael Van Canneyt via fpc-pascal said on Tue, 30 May 2023 16:55:16 +0200 (CEST) >On Tue, 30 May 2023, Hairy Pixels via fpc-pascal wrote: > >> >> >>> On May 25, 2023, at 1:10 PM, Michael Van Canneyt via fpc-pascal >>> wrote: >>> >>> >>> In C you need to do something like this: >>> >>>

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-30 Thread Michael Van Canneyt via fpc-pascal
On Tue, 30 May 2023, Hairy Pixels via fpc-pascal wrote: On May 25, 2023, at 1:10 PM, Michael Van Canneyt via fpc-pascal wrote: In C you need to do something like this: Function MyFunction(out theresult : TResultType) : Integer; begin Allocate A ... error condition 1: Free A,

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-30 Thread Hairy Pixels via fpc-pascal
> On May 25, 2023, at 1:10 PM, Michael Van Canneyt via fpc-pascal > wrote: > > > In C you need to do something like this: > > Function MyFunction(out theresult : TResultType) : Integer; > > begin > Allocate A > ... > error condition 1: >Free A, exit (1); > ... > Allocate B >

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-26 Thread Thomas Kurz via fpc-pascal
, it seems ridiculous to discuss about 39 bytes! - Original Message - From: Benito van der Zander via fpc-pascal To: fpc-pascal@lists.freepascal.org Sent: Thursday, May 25, 2023, 22:49:08 Subject: [fpc-pascal] Freeing memory with exceptions Hi, > That 99.99% of people does

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Steve Litt via fpc-pascal
Benito van der Zander via fpc-pascal said on Wed, 24 May 2023 13:00:04 +0200 >I regret installing Linux. Everything worked better with Windows 98 >and Delphi 4 Why not just take your Win98 install disk, install win98, then take your Delphi 4 install disk, install Delphi 4, and you're all set.

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Michael Van Canneyt via fpc-pascal
On Thu, 25 May 2023, Benito van der Zander via fpc-pascal wrote: Hi, That 99.99% of people does use it, indicates they simply take the overhead because of the advantages that the managed types offer. Or they simply do not know about the overhead If people don't know there is

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Benito van der Zander via fpc-pascal
Hi, That 99.99% of people does use it, indicates they simply take the overhead because of the advantages that the managed types offer. Or they simply do not know about the overhead Like I was writing all my code on Windows 98, and never noticed any overhead, until I started running

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Sven Barth via fpc-pascal
Mattias Gaertner via fpc-pascal schrieb am Do., 25. Mai 2023, 08:23: > On Thu, 25 May 2023 07:55:39 +0200 > Sven Barth via fpc-pascal wrote: > > >[...] > > But this is what "managed type" *means*: that the compiler and RTL > > will make sure that it's correctly freed as long as nothing > >

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Mattias Gaertner via fpc-pascal
On Thu, 25 May 2023 07:55:39 +0200 Sven Barth via fpc-pascal wrote: >[...] > But this is what "managed type" *means*: that the compiler and RTL > will make sure that it's correctly freed as long as nothing > unexpected happens. ... and exceptions are expected. Maybe better: As long as the user

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Michael Van Canneyt via fpc-pascal
On Thu, 25 May 2023, Hairy Pixels via fpc-pascal wrote: On May 24, 2023, at 8:46 PM, Michael Van Canneyt via fpc-pascal wrote: I see no problem, I am used to this. This is Pascal, you need to manage your memory and hence your references, this is true even in the absence of

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-25 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Do., 25. Mai 2023, 04:32: > > > > On May 24, 2023, at 8:46 PM, Michael Van Canneyt via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > I see no problem, I am used to this. > > > > This is Pascal, you need to manage your memory and hence your

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Michael Van Canneyt via fpc-pascal
On Thu, 25 May 2023, Hairy Pixels via fpc-pascal wrote: On May 24, 2023, at 10:11 PM, Sven Barth via fpc-pascal wrote: You must have $H+ on and those are AnsiStrings? Why is there exception handling involved with AnsiString? I guess it needs this just in case an exception is thrown

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Do., 25. Mai 2023, 04:26: > > > > On May 24, 2023, at 10:11 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > You must have $H+ on and those are AnsiStrings? Why is there exception > handling involved with AnsiString? I guess

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Hairy Pixels via fpc-pascal
> On May 24, 2023, at 8:46 PM, Michael Van Canneyt via fpc-pascal > wrote: > > I see no problem, I am used to this. > > This is Pascal, you need to manage your memory and hence your references, > this is true even in the absence of exceptions: In your example you would > also need to

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Hairy Pixels via fpc-pascal
> On May 24, 2023, at 10:11 PM, Sven Barth via fpc-pascal > wrote: > > You must have $H+ on and those are AnsiStrings? Why is there exception > handling involved with AnsiString? I guess it needs this just in case an > exception is thrown somewhere in the call stack? > > Because Ansi- and

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Sven Barth via fpc-pascal
Benito van der Zander via fpc-pascal schrieb am Do., 25. Mai 2023, 00:15: > Hi > > > Then also run FPC/win32 in wine for a real comparison. > > > Or perhaps against modern C++ on Linux would also be a real comparison > It wouldn't be, because that would compare two different languages. C++

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Benito van der Zander via fpc-pascal
Hi Then also run FPC/win32 in wine for a real comparison. Or perhaps against modern C++ on Linux would also be a real comparison FPC could at least inline fpc_setjmp in fpc_pushexceptaddr to make it only one function call. These kinds of statements are counter-productive. That is a

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Mi., 24. Mai 2023, 14:10: > You must have $H+ on and those are AnsiStrings? Why is there exception > handling involved with AnsiString? I guess it needs this just in case an > exception is thrown somewhere in the call stack? Because Ansi- and

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Michael Van Canneyt via fpc-pascal
On Wed, 24 May 2023, Hairy Pixels via fpc-pascal wrote: On May 21, 2023, at 11:03 PM, Michael Van Canneyt via fpc-pascal wrote: They're used all over the place in the RTL and FCL, so you better take them into account. The compiler will do this wrapping anyway if you use ansistrings,

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Hairy Pixels via fpc-pascal
> On May 21, 2023, at 11:03 PM, Michael Van Canneyt via fpc-pascal > wrote: > > They're used all over the place in the RTL and FCL, so you better take them > into account. > > The compiler will do this wrapping anyway if you use ansistrings, so the > approach with e.g. a generic record will

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Hairy Pixels via fpc-pascal
You must have $H+ on and those are AnsiStrings? Why is there exception handling involved with AnsiString? I guess it needs this just in case an exception is thrown somewhere in the call stack? > On May 23, 2023, at 5:44 PM, Benito van der Zander via fpc-pascal > wrote: > > Like take: > >

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Sven Barth via fpc-pascal
Benito van der Zander via fpc-pascal schrieb am Mi., 24. Mai 2023, 13:00: > Hi, > > It is weird that your code calls setjmp? Are you using a non Windows > platform? Comparisons with Delphi should be done on Windows where the > exception systems match. Apples to Apples please. > > > It is FPC on

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Marco van de Voort via fpc-pascal
On 24-5-2023 13:00, Benito van der Zander via fpc-pascal wrote: It is weird that your code calls setjmp? Are you using a non Windows platform?  Comparisons with Delphi should be done on Windows where the exception systems match. Apples to Apples please. It is FPC on Linux. And Delphi 4 on

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Benito van der Zander via fpc-pascal
Hi, It is weird that your code calls setjmp? Are you using a non Windows platform?  Comparisons with Delphi should be done on Windows where the exception systems match. Apples to Apples please. It is FPC on Linux. And Delphi 4 on Linux (in WINE) Even if it wants to do the Linux nonsense,

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-24 Thread Marco van de Voort via fpc-pascal
On 23-5-2023 12:44, Benito van der Zander via fpc-pascal wrote: Hi, Depends on your code. I wrote all my code in Delphi 4. From 1998 or so. I do not make new projects, only maintain old ones. Delphi 4 felt much better. Like take: procedure test; var s: string; begin   s:= 'abc'; end;

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Michael Van Canneyt via fpc-pascal
On Mon, 22 May 2023, Benito van der Zander via fpc-pascal wrote: Hi, The compiler will do this wrapping anyway if you use ansistrings, so the approach with e.g. a generic record will not cause a lot of overhead in most cases. But using strings or anything similar causes a lot of

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Benito van der Zander via fpc-pascal
Hi, The compiler will do this wrapping anyway if you use ansistrings, so the approach with e.g. a generic record will not cause a lot of overhead in most cases. But using strings or anything similar causes a lot of overhead It is really bad Bye, Benito On 21.05.23 18:03, Michael Van

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Michael Van Canneyt via fpc-pascal
On Mon, 22 May 2023, Steve Litt via fpc-pascal wrote: Michael Van Canneyt via fpc-pascal said on Sun, 21 May 2023 09:47:15 +0200 (CEST) On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: I've never really used exceptions myself in Pascal (with the exception of breaking out of deeply

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Steve Litt via fpc-pascal
Michael Van Canneyt via fpc-pascal said on Sun, 21 May 2023 09:47:15 +0200 (CEST) >Assuming the result of A is not used outside of Test, the following is >the only solution: > >procedure Test; > >var > A : TObject; >begin > A:=TObject.Create; > Try > // call some code in other unit which

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-22 Thread Steve Litt via fpc-pascal
Michael Van Canneyt via fpc-pascal said on Sun, 21 May 2023 09:47:15 +0200 (CEST) >On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: > >> I've never really used exceptions myself in Pascal (with the >> exception of breaking out of deeply recursive function calls) so I >> don't know all the

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Michael Van Canneyt via fpc-pascal
On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: On May 21, 2023, at 2:47 PM, Michael Van Canneyt via fpc-pascal wrote: Your example will leak memory in any case, even if there is no exception, since you're not freeing the object anywhere.. doh, dumb example on my behalf.

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Hairy Pixels via fpc-pascal
> On May 21, 2023, at 2:47 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Your example will leak memory in any case, even if there is no exception, > since you're not freeing the object anywhere.. doh, dumb example on my behalf. > > Assuming the result of A is not used outside of

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Michael Van Canneyt via fpc-pascal
On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: I've never really used exceptions myself in Pascal (with the exception of breaking out of deeply recursive function calls) so I don't know all the rules. In this example lets say you call Test() which allocates some memory and then

[fpc-pascal] Freeing memory with exceptions

2023-05-20 Thread Hairy Pixels via fpc-pascal
I've never really used exceptions myself in Pascal (with the exception of breaking out of deeply recursive function calls) so I don't know all the rules. In this example lets say you call Test() which allocates some memory and then calls out to another function in another unit which raises (the