[fpc-pascal] Range checks
skalogryz.lists at gmail.com
Sat Jan 27 18:51:49 CET 2018
On Sat, Jan 27, 2018 at 12:30 PM, C Western <l at c-m-w.me.uk> wrote:
> The actual code that triggered my interest was:
> procedure LCLViewExtension.lclSetEnabled(AEnabled: Boolean);
> ns : NSArray;
> i : integer;
> obj : NSObject;
> ns := subviews;
> for i := 0 to ns.count - 1 do
> obj := NSObject(ns.objectAtIndex( i ));
> ... process obj ...
> Given how common the above bit of code is likely to be, I can't see any
> way of fixing this without some work in the compiler.
imho, bad approach to adjust compiler for not safe code.
However, getting a compiler warning would be nice.
Some time ago, the compiler has been extended with for-in syntax:
SubView : NSView;
for SubView in ns.subviews do
.. process obj ...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal