I learn C by reading Tanenbaum and Comer's OS books, and I cannot
imagine how putting variable declarations anywhere other than the top of
the function they belong to, would make sense. Unless they are global,
in which case they go in a suitably global header file.
Wesley Parish
On 4/04/24 06:30, segaloco via COFF wrote:
On Wednesday, April 3rd, 2024 at 9:18 AM, Paul
Winalski <paul.winalski(a)gmail.com> wrote:
In the PL/I shops I worked at it was required
that all declarations be at the beginning of the scope block.
-Paul W.
I get (friendly) flack for this from some of my coworkers, context is
we're a C# and Java(Type)Script shop. They poke fun at how I write these languages
like a C programmer but I don't ever hear anyone complaining about the readability of
my code :)
Declarations anywhere else but the top of blocks irks me, even if the language is totally
fine with it. The only exception is asm, putting all the data and bss at the bottom of
assembly units instead.
- Matt G.