<div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
> > 1. it makes it easier to see the whole picture just looking at the loop<br>
> > body, no need to scroll up; (The loop body might be just 10 lines of code,<br>
> > whereas the whole containing function sometimes has 1000s)<br>
> ><br>
> > 2. it isoltates the scope of such variable(s), therefore preventing some<br>
> > sorts of accidental misuse outside of e.g. the containing loop (which still<br>
> > do happen to me ocasionally in Pascal).<br>
><br>
> I've already tried to make these points, nobody seems to buy it. IIRC<br>
> Michael (vC) said that functions shouldn't be that long, so then it's<br>
> not a problem (perhaps his world is perfect, but mine certainly isn't).<br>
<br>
Anyone can split a function in many others. It's not so difficult and,<br>
actually, it should be done.<br>
<br>
> I'm mostly more interested in limiting the scope to prevent accidental<br>
> use, like you. It can also offer more fine grained control of where<br>
> managed variables get freed.<br>
<br>
Try to see restrictions as a good thing.<br>
In this case, which Pascal doesn't allow to declare inline variables,<br>
you must split big functions, which has many local variables, in<br>
others to have a better understanding of the algorithm. At the end,<br>
you might have a better design and reuse of the code. Everybody wins:<br>
you, your code, Pascal team - as they don't need to change the<br>
compiler - and Niklaus Wirth might not throw a curse in us.<br><br></blockquote><div><br></div><div>O dear, now I've dunnit... </div><div><br></div><div>So the argument against is: (1) split your long functions, because you should; and (2) Wirth didn't do it, so good it is not.</div><div><br></div><div>Long functions *might* be an indication of bad design, but you know, sometimes I have a long function that doesn't make sense to split.</div><div><br></div><div>Here is a good article about inline vars: <a href="http://blog.marcocantu.com/blog/2018-october-inline-variables-delphi.html">http://blog.marcocantu.com/blog/2018-october-inline-variables-delphi.html</a></div><div><br></div><div>What's not to like about for var I:=0 to Count-1 do.. ?</div><div><br></div><div>Or var MyDict:=TDictionary<Integer,String>.Create;</div><div><br></div><div>Marcos says restrictions are good. The above restricts the number of lines of code while being just as (or more) readable!</div><div><br></div></div></div></div>