Tommi Prami 130 Posted February 6, 2020 (edited) With haters unite, please vote for this : https://quality.embarcadero.com/browse/RSP-18953 Compiler (etc) assisted with removal Refactoring tool would be super cool. Sometimes so error prone to remove by hand, especially nested withs. (oops wrong link at start) Edited February 6, 2020 by Tommi Prami Share this post Link to post
Uwe Raabe 2057 Posted February 6, 2020 The filter "Reported by me" yields different results for everyone - obviously. Share this post Link to post
Sherlock 663 Posted February 6, 2020 I see issue 21814...I see no with. Both eyes open...Brain perhaps not at 100% though. Share this post Link to post
Lars Fosdal 1792 Posted February 6, 2020 Did you mean https://quality.embarcadero.com/browse/RSP-18953 - Tommi? 21814 is the Windows 10 Ansi/UTF-8 QP - which, by the way, returns different values on my Windows 10 Enterprise 1809 10.0.17763.831, depending on which PowerShell version you use. PowerShell 5.1 IsSingleByte : True BodyName : iso-8859-1 EncodingName : Western European (Windows) HeaderName : Windows-1252 WebName : Windows-1252 WindowsCodePage : 1252 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : True IsMailNewsSave : True EncoderFallback : System.Text.InternalEncoderBestFitFallback DecoderFallback : System.Text.InternalDecoderBestFitFallback IsReadOnly : True CodePage : 1252 PowerShell 6.2.4 Preamble : BodyName : utf-8 EncodingName : Unicode (UTF-8) HeaderName : utf-8 WebName : utf-8 WindowsCodePage : 1200 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : True IsMailNewsSave : True IsSingleByte : False EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 65001 Share this post Link to post
Lars Fosdal 1792 Posted February 6, 2020 I'd like this to be possible, and a compiler switch that bans the old with statements. with var ref := Some.Array[Index1].Reference, var thing := Function(Index1).Thing do begin if ref.Value <> thing.Value then begin ... end; end; // ref and thing are not present 1 Share this post Link to post
Tommi Prami 130 Posted February 6, 2020 Damnation, right. This is correct URL: https://quality.embarcadero.com/browse/RSP-18953 Thanks... Copy paste errors all day 😄 -tee- 1 Share this post Link to post
Tommi Prami 130 Posted February 6, 2020 Sorry about all link hassle.. -tee- Share this post Link to post
Wagner Landgraf 43 Posted February 6, 2020 2 hours ago, Lars Fosdal said: I'd like this to be possible, and a compiler switch that bans the old with statements. with var ref := Some.Array[Index1].Reference, var thing := Function(Index1).Thing do begin if ref.Value <> thing.Value then begin ... end; end; // ref and thing are not present It is, it's called inline variables... 😉 Share this post Link to post
Lars Fosdal 1792 Posted February 6, 2020 16 minutes ago, Wagner Landgraf said: It is, it's called inline variables... 😉 True, but the point is a more natural limit of variable scope. var ref := Some.Array[Index1].Reference; var thing := Function(Index1).Thing; if ref.Value <> thing.Value then begin ... end; // ref and thing ARE present here I guess you could wrap it in another pair of begin/end - but that would look a bit strange, while the with signals clearly that these are local. Share this post Link to post
Anders Melander 1782 Posted February 6, 2020 7 minutes ago, Lars Fosdal said: I guess you could wrap it in another pair of begin/end - but that would look a bit strange, while the with signals clearly that these are local. You already have a begin...end pair: with whatever do begin end; So why not just move the inline inside the begin...end and get rid of the with: begin var thisorthat := whatever; ... end; I see no reason to change the language so we can keep using with. Just get rid of it and forget it ever existed. 3 1 Share this post Link to post
Uwe Raabe 2057 Posted February 6, 2020 (edited) Indeed! You would write it this way: begin ... begin // do something with ref and thing var ref := Some.Array[Index1].Reference; var thing := Function(Index1).Thing if ref.Value <> thing.Value then begin ... end; end; // ref and thing are not present ... end; Edited February 6, 2020 by Uwe Raabe Share this post Link to post