<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body smarttemplateinserted="true">
<div id="smartTemplate4-template">Hi,<br>
<br>
<blockquote type="cite"><br>
The compiler will do this wrapping anyway if you use
ansistrings, so the
<br>
approach with e.g. a generic record will not cause a lot of
overhead in most
<br>
cases.
</blockquote>
<br>
But using strings or anything similar causes a lot of overhead<br>
<p>It is really bad<br>
</p>
<br>
<br>
Bye,<br>
Benito <br>
</div>
<div class="moz-cite-prefix">On 21.05.23 18:03, Michael Van Canneyt
via fpc-pascal wrote:<br>
</div>
<blockquote type="cite"
cite="mid:alpine.DEB.2.22.394.2305211759400.196463@home">
<br>
<br>
On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote:
<br>
<br>
<blockquote type="cite">
<br>
<br>
<blockquote type="cite">On May 21, 2023, at 2:47 PM, Michael Van
Canneyt via fpc-pascal <a class="moz-txt-link-rfc2396E" href="mailto:fpc-pascal@lists.freepascal.org"><fpc-pascal@lists.freepascal.org></a>
wrote:
<br>
<br>
Your example will leak memory in any case, even if there is no
exception,
<br>
since you're not freeing the object anywhere..
<br>
</blockquote>
<br>
doh, dumb example on my behalf.
<br>
<br>
<blockquote type="cite">
<br>
Assuming the result of A is not used outside of Test, the
following is the
<br>
only solution:
<br>
<br>
procedure Test;
<br>
<br>
var
<br>
A : TObject;
<br>
begin
<br>
A:=TObject.Create;
<br>
Try
<br>
// call some code in other unit which raise an exception
<br>
DoThis;
<br>
finally
<br>
A.Free
<br>
end;
<br>
end;
<br>
<br>
You can try to use interfaces, they will be managed by the
compiler.
<br>
</blockquote>
<br>
This is what I was worried about, wrapping all functions or
needing full ARC on all types. Very risk to opt in to this
design I would say. I remain not a fan of exceptions. :)
<br>
</blockquote>
<br>
They're used all over the place in the RTL and FCL, so you better
take them
<br>
into account.
<br>
<br>
The compiler will do this wrapping anyway if you use ansistrings,
so the
<br>
approach with e.g. a generic record will not cause a lot of
overhead in most
<br>
cases.
<br>
<br>
Michael.
<br>
_______________________________________________
<br>
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
<br>
</blockquote>
</body>
</html>