Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: "Luke A. Guest" Newsgroups: comp.compilers Subject: Re: another C-like language? was Compilers :) Date: Fri, 13 Jan 2023 18:25:37 +0000 Organization: Aioe.org NNTP Server Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <23-01-052@comp.compilers> References: <23-01-001@comp.compilers> <23-01-002@comp.compilers> <23-01-003@comp.compilers> <23-01-008@comp.compilers> <23-01-016@comp.compilers> <23-01-029@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-GB Xref: csiph.com comp.compilers:3320 On 09/01/2023 17:41, Kaz Kylheku wrote: > On 2023-01-06, David Brown 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.