Related articles |
---|
[14 earlier articles] |
Re: another C-like language? was Compilers :) david.brown@hesbynett.no (David Brown) (2023-01-10) |
Re: another C-like language? was Compilers :) gah4@u.washington.edu (gah4) (2023-01-10) |
Re: another C-like language? was Compilers :) tkoenig@netcologne.de (Thomas Koenig) (2023-01-11) |
Re: another C-like language? was Compilers :) 864-117-4973@kylheku.com (Kaz Kylheku) (2023-01-11) |
Re: another C-like language? was Compilers :) findlaybill@blueyonder.co.uk (Bill Findlay) (2023-01-11) |
Re: another C-like language? was Compilers :) david.brown@hesbynett.no (David Brown) (2023-01-11) |
Re: another C-like language? was Compilers :) laguest@archeia.com (Luke A. Guest) (2023-01-13) |
Re: another C-like language? was Compilers :) gneuner2@comcast.net (George Neuner) (2023-01-13) |
Re: another C-like language? was Compilers :) 864-117-4973@kylheku.com (Kaz Kylheku) (2023-01-14) |
Re: another C-like language? was Compilers :) marblypup@yahoo.co.uk (marb...@yahoo.co.uk) (2023-01-15) |
Re: another C-like language? was Compilers :) marblypup@yahoo.co.uk (marb...@yahoo.co.uk) (2023-01-15) |
Re: another C-like language? was Compilers :) anw@cuboid.co.uk (Andy Walker) (2023-01-15) |
From: | "Luke A. Guest" <laguest@archeia.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 13 Jan 2023 18:25:37 +0000 |
Organization: | Aioe.org NNTP Server |
References: | 23-01-001 23-01-002 23-01-003 23-01-008 23-01-016 23-01-029 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="95524"; mail-complaints-to="abuse@iecc.com" |
Keywords: | C, standards |
Posted-Date: | 13 Jan 2023 14:09:25 EST |
Content-Language: | en-GB |
On 09/01/2023 17:41, Kaz Kylheku wrote:
> On 2023-01-06, David Brown <david.brown@hesbynett.no> wrote:
>> don't want to go through them all, but I agree with you that the style
>> of "all your declarations at the start of the function" is long
>> outdated, and often - but not universally - considered a bad idea.)
>
> Declarations have never been required to be at the top of a function in
> C, because they can be in any compound statement block. I think
> that goes all the way back to the B language. [Nope, see the next message. -John]
When I learnt C, you had to define your variables at the top of the
block {} whether that's a function or a block within the function somewhere.
> The "Variables at the top" meme may be something coming from Pascal.
Nope. Algol. C is an Algol derived language.
> IIRC, in Pascal, compound statements aren't full blocks; they cannot
> have VAR declarations.
>
> When programmers abandoned Pascal in the 1980s, they carried over this
> habit into C.
Nope, this was defined in the C spec and the K&R book. Apparently this
has been relaxed recently-ish and now variables can be defined anywhere.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.