Re: [Lazarus] Redundant assigned(X) and (X is Txxx) in Laz. sources
On Sat, 13 Jan 2018 13:01:33 +0800 Dennis via Lazaruswrote: >[...] > I am now confused, so > in FPC, it is safe to just use: if LookupRoot is TWinControl >instead of > if assigned(LookupRoot) and (LookupRoot is TWinControl) then Yes. > is it safe to > with LookupRoot as TWinControl do begin > > end; No. > or should I always > if assigned(LookupRoot) then > with LookupRoot as TWinControl do begin > > end; Yes. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Redundant assigned(X) and (X is Txxx) in Laz. sources
Mattias Gaertner via Lazarus wrote: On Fri, 12 Jan 2018 21:44:47 +0200 Juha Manninen via Lazaruswrote: On Fri, Jan 12, 2018 at 8:38 PM, Vojtěch Čihák via Lazarus wrote: I wrote a small routine to search Lazarus sources and it found about 60 places similar to this (taborderdlg.pas, line 398): if Assigned(LookupRoot) and (LookupRoot is TWinControl) then begin Should I make a patch for all occurences? Yes, I think the patch would be applied. IIRC "is" was not allowed with Nil references in old FPC versions but it was a long time ago. No, "is" was always checking for nil. Maybe some people are confused by "as", which does not check for nil. Mattias I am now confused, so in FPC, it is safe to just use: if LookupRoot is TWinControl instead of if assigned(LookupRoot) and (LookupRoot is TWinControl) then is it safe to with LookupRoot as TWinControl do begin end; or should I always if assigned(LookupRoot) then with LookupRoot as TWinControl do begin end; Dennis -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Redundant assigned(X) and (X is Txxx) in Laz. sources
On Fri, 12 Jan 2018 21:44:47 +0200 Juha Manninen via Lazaruswrote: > On Fri, Jan 12, 2018 at 8:38 PM, Vojtěch Čihák via Lazarus > wrote: > > I wrote a small routine to search Lazarus sources and it found about 60 > > places similar to this (taborderdlg.pas, line 398): > > > > if Assigned(LookupRoot) and (LookupRoot is TWinControl) then begin > > > > Should I make a patch for all occurences? > > Yes, I think the patch would be applied. > IIRC "is" was not allowed with Nil references in old FPC versions but > it was a long time ago. No, "is" was always checking for nil. Maybe some people are confused by "as", which does not check for nil. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Redundant assigned(X) and (X is Txxx) in Laz. sources
On Fri, Jan 12, 2018 at 8:38 PM, Vojtěch Čihák via Lazaruswrote: > I wrote a small routine to search Lazarus sources and it found about 60 > places similar to this (taborderdlg.pas, line 398): > > if Assigned(LookupRoot) and (LookupRoot is TWinControl) then begin > > Should I make a patch for all occurences? Yes, I think the patch would be applied. IIRC "is" was not allowed with Nil references in old FPC versions but it was a long time ago. BTW, a regular expression search in the Find in Files dialog would have found those cases, too. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] Redundant assigned(X) and (X is Txxx) in Laz. sources
Hi, I wrote a small routine to search Lazarus sources and it found about 60 places similar to this (taborderdlg.pas, line 398): if Assigned(LookupRoot) and (LookupRoot is TWinControl) then begin Should I make a patch for all occurences? V. -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus