On Sat, Jan 27, 2018 at 12:30 PM, C Western <l...@c-m-w.me.uk> wrote:
>
> The actual code that triggered my interest was:
>
> procedure LCLViewExtension.lclSetEnabled(AEnabled: Boolean);
> var
>   ns : NSArray;
>   i  : integer;
>   obj : NSObject;
> begin
>   ns := subviews;
>   for i := 0 to ns.count - 1 do
>   begin
>     obj := NSObject(ns.objectAtIndex( i ));
>     ... process obj ...
>   end;
> end;
>
>
> 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:

var
  SubView : NSView;
begin
  for SubView in ns.subviews do
  begin
    .. process obj ...
  end

thanks,
Dmitry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to