<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,<br>
</p>
<div class="moz-cite-prefix">Στις 20/2/2019 4:46 μ.μ., ο Paul van
Helden έγραψε:<br>
</div>
<blockquote type="cite"
cite="mid:CAPjGFZfS7CzviiAKS7ew_Smff0OtQ7XVNiZ83Es0qONpt6Z7wg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">On Wed, Feb 20, 2019 at 4:35 PM Dimitrios Chr.
Ioannidis via fpc-devel <<a
href="mailto:fpc-devel@lists.freepascal.org"
moz-do-not-send="true">fpc-devel@lists.freepascal.org</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">
<div bgcolor="#FFFFFF">
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote"> </div>
</div>
</div>
</blockquote>
<p> Even if declaring variables as close as possible to
where the variable will be used ( debugging wise not
readability wise ) leads to more correct code, the
problem is to avoid the temptation to use them in other
places too. <br>
</p>
</div>
</blockquote>
<div>Variables declared within a begin...end cannot be used
elsewhere. (E.g. for var I:=0 to .. won't let you use I
after the loop).</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p> </p>
<p> AFAIK, one of Pascal's primary design goals is to
won't let you shoot yourself in the foot, and IMO that
feature is not in that direction.</p>
</div>
</blockquote>
<div> I'd like to see an example how this is less safe.</div>
</div>
</div>
</blockquote>
<p>Well one of the answer in the Cantu blog has this ( which I
changed to lets say a "real world" relative big function ) :</p>
<pre style="background-color: white; border: none; font-family: Lola; font-size: 18px">var arr: array...
function Fuckup: boolean;
var I: Integer;
begin
<....> 20 lines of code
for var I := Low(arr) to High(arr) do
if arr[I]..... then
break;
<....> 20 lines of code
Result := (I <= High(arr));
end;
regards,
--
Dimitrios Chr. Ioannidis
</pre>
</body>
</html>