[fpc-pascal] Freeing memory with exceptions

Benito van der Zander benito at benibela.de
Tue May 23 12:44:07 CEST 2023


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;

And Delphi 4 produces great looking output. 64 bytes. A few mov and push 
for exception handling:


FPC nowadays. 103 bytes. 4 functions calls for exception handling! 3 
even if there are no exceptions. Unbelievable that it needs that many 
function calls





>
>
> Nobody forces you to use ansistrings or unicodestrings. You can 
> perfectly write your own library for string management if you are
> so inclined.

I wrote my own using pchars: 
https://github.com/benibela/bbutils/blob/master/bbutils.pas#L328-L950



Sincerely,
Benito
On 22.05.23 23:06, Michael Van Canneyt via fpc-pascal wrote:
>
>
> 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 overhead
>>
>> It is really bad
>
> Depends on your code.
>
> Nobody forces you to use ansistrings or unicodestrings. You can 
> perfectly write your own library for string management if you are
> so inclined.
>
> But I for one am grateful that I don't need to bother with memory 
> management for
> strings, except perhaps on special occasions.
>
> So I think it is really good.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230523/a748fed9/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: M8D9SqzaqUZTGKgq.png
Type: image/png
Size: 39113 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230523/a748fed9/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4u1L1lnXUO20VRJd.png
Type: image/png
Size: 183536 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230523/a748fed9/attachment-0003.png>


More information about the fpc-pascal mailing list