<div dir="ltr"><div dir="ltr">On Tue, Jul 2, 2019 at 7:38 PM Ondrej Pokorny <<a href="mailto:lazarus@kluug.net">lazarus@kluug.net</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
A good real-word example is the cast from a pointer:<br>
<br>
program Project1;<br>
uses Classes;<br>
var<br>
Value: TPersistent;<br>
P: Pointer;<br>
begin<br>
P := TObject.Create;<br>
Value := TPersistent(P);<br>
if Value is TPersistent then<br>
Writeln('Value is TPersistent')<br>
else<br>
Writeln('Value is not TPersistent');<br>
Readln;<br>
end.<br></blockquote><div><br></div><div>In general, assuming P was a pointer initialized elsewhere (meaning you really didn't know what it was), why wouldn't you just write this:</div><div><br></div><div> if TObject(P) is TPersistent then<br> Writeln('Value is TPersistent')<br> else<br> Writeln('Value is not TPersistent');<br> Readln;<br></div><div><br></div><div>Behaves as you'd expect, and doesn't require an additional variable.</div></div></div>