Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.c++ Subject: Re: Overuse of 'auto' Date: Tue, 20 Dec 2022 14:45:49 +0000 Organization: A noiseless patient Spider Lines: 35 Message-ID: <87o7ryuo9u.fsf@bsb.me.uk> References: <539f793b-c112-4d35-a907-64351d1e2835n@googlegroups.com> <043c4a79-2f9b-4c37-9383-481dd6f3dbc2n@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: reader01.eternal-september.org; posting-host="b0c36667ceca199949af0c336901b51b"; logging-data="756764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EkBjKkQvljMGY8H8KrRw8DA5Tc9KnnJk=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:EknmFtMu+m9QB3ek3GmkRPnrrwk= sha1:u6K5TjEas39+0viOfV2T9fv0oHg= X-BSB-Auth: 1.48523167e832c77de7c3.20221220144549GMT.87o7ryuo9u.fsf@bsb.me.uk Xref: csiph.com comp.lang.c++:88135 Juha Nieminen writes: > Öö Tiib wrote: >> On Monday, 19 December 2022 at 17:55:23 UTC+2, Juha Nieminen wrote: >>> Öö Tiib wrote: >>> > So your good example is: >>> > for(size_t image_index = 0; image_index < images.size(); ++image_index) >>> > Lot easier than with "i"? >>> Easier to read and understand, yes. Absolutely. >>> >>> The longer the loop body, the more it helps. If there are nested loops, >>> it helps even more. (Conversely, the longer the loop body and the >>> more nested loops there are, the more obscure the 'i' becomes, as it >>> gets buried in the code and it's harder to find and remember what >>> it is. Heaven forbid you mix it with 'j'. Now you are just writing >>> obfuscated code.) >>> >> I do not know, for me it is no problem to see that i is indexing images >> from shorter form just with passing glance. If I somehow forget it >> during reading next line (how?) then I can look again. > > I'm not sure how I could convey my experience on both reading (huge > amounts of) other people's code and writing my own code and then > reading it months/later, and noticing how much easier it becomes > to read when, for example, loop variables express what they are > indexing or counting. I suspect that part of the trouble is that people "read" code in different ways. From your descriptions it really seems like you do it differently to how I do it. If you think this might be a productive avenue (i.e. you don't think I am just being stubborn) I'd be happy to say more. -- Ben.