<br><br><div class="gmail_quote">On 18 October 2010 14:42, Florian Klaempfl <span dir="ltr"><<a href="mailto:florian@freepascal.org">florian@freepascal.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Am 18.10.2010 14:58, schrieb Frank Church:<br>
<div class="im">><br>
><br>
> On 18 October 2010 07:49, Florian Klaempfl <<a href="mailto:florian@freepascal.org">florian@freepascal.org</a><br>
</div><div class="im">> <mailto:<a href="mailto:florian@freepascal.org">florian@freepascal.org</a>>> wrote:<br>
><br>
> Am 18.10.2010 08:17, schrieb Zaher Dirkey:<br>
> ><br>
> ><br>
> > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt<br>
> > <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a> <mailto:<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>><br>
</div><div class="im">> <mailto:<a href="mailto:michael@freepascal.org">michael@freepascal.org</a> <mailto:<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>>>> wrote:<br>
> ><br>
> ><br>
> ><br>
> > On Thu, 14 Oct 2010, Frank Church wrote:<br>
> ><br>
> > Can variables be declared within a begin end block?<br>
> ><br>
> ><br>
> > No.<br>
> ><br>
><br>
><br>
> That is a rather emphatic no :).<br>
> Is there some performance or other related reason why it is a bad idea?<br>
<br>
</div>It's just a matter of readability, e.g. having a variable declared in<br>
two blocks with the same name can cause you a lot of headache:<br>
<br>
procedure p;<br>
<br>
begin<br>
...<br>
begin<br>
var i : integer;<br>
...<br>
...<br>
...<br>
i:=12341234;<br>
...<br>
...<br>
...<br>
...<br>
end;<br>
...<br>
...<br>
...<br>
begin<br>
var i : integer;<br>
...<br>
writeln(i); <--- this i is not the same as above so i does not<br>
contain 12341234 but it contains probably some garbage.<br>
end;<br></blockquote><div><br><br>My need is not for such kind or variables - it is for something like this.<br><br>say I have some thing like:<br> StringList.NameOfIndex(TableName.FieldByName('xxxx').AsString) > AnotherEqualLongExpression + SomeOtherEvenLongerExpression.<br>
<br>I just want to create shorter variables like<br>si := StringList.NameOfIndex(TableName.FieldByName('xxxx').AsString);<br>ae := xxx;<br>so:= yyy<br><br>to express complicated logic with them.<br><br>When I put them all at the top of the procedure, they are extra noise, which is not necessary for the understanding the purpose at the top level of the procedure.<br>
<br>I understand the need to avoid stuff that could create unintended errors and have experienced such issues before. I will be careful not to use the more than enough rope I have been given to hang myself. I promise :)<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>