[fpc-devel] "Blank slate" next version of FPC

Dimitrios Chr. Ioannidis d.ioannidis at nephelae.eu
Wed Feb 20 16:24:19 CET 2019


Hi,

Στις 20/2/2019 4:46 μ.μ., ο Paul van Helden έγραψε:
> On Wed, Feb 20, 2019 at 4:35 PM Dimitrios Chr. Ioannidis via fpc-devel 
> <fpc-devel at lists.freepascal.org 
> <mailto:fpc-devel at lists.freepascal.org>> wrote:
>
>       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.
>
> 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).
>
>       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.
>
>  I'd like to see an example how this is less safe.

Well one of the answer in the Cantu blog has this ( which I changed to 
lets say a "real world" relative big function ) :

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190220/3a2e0613/attachment.html>


More information about the fpc-devel mailing list