On 18 October 2010 14:42, Florian Klaempfl <flor...@freepascal.org> wrote:
> Am 18.10.2010 14:58, schrieb Frank Church: > > > > > > On 18 October 2010 07:49, Florian Klaempfl <flor...@freepascal.org > > <mailto:flor...@freepascal.org>> wrote: > > > > Am 18.10.2010 08:17, schrieb Zaher Dirkey: > > > > > > > > > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt > > > <mich...@freepascal.org <mailto:mich...@freepascal.org> > > <mailto:mich...@freepascal.org <mailto:mich...@freepascal.org>>> > wrote: > > > > > > > > > > > > On Thu, 14 Oct 2010, Frank Church wrote: > > > > > > Can variables be declared within a begin end block? > > > > > > > > > No. > > > > > > > > > That is a rather emphatic no :). > > Is there some performance or other related reason why it is a bad idea? > > It's just a matter of readability, e.g. having a variable declared in > two blocks with the same name can cause you a lot of headache: > > procedure p; > > begin > ... > begin > var i : integer; > ... > ... > ... > i:=12341234; > ... > ... > ... > ... > end; > ... > ... > ... > begin > var i : integer; > ... > writeln(i); <--- this i is not the same as above so i does not > contain 12341234 but it contains probably some garbage. > end; > My need is not for such kind or variables - it is for something like this. say I have some thing like: StringList.NameOfIndex(TableName.FieldByName('xxxx').AsString) > AnotherEqualLongExpression + SomeOtherEvenLongerExpression. I just want to create shorter variables like si := StringList.NameOfIndex(TableName.FieldByName('xxxx').AsString); ae := xxx; so:= yyy to express complicated logic with them. 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. 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 :) > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- Frank Church ======================= http://devblog.brahmancreations.com
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal