Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Two questions on arrays with size defined by variables Date: Sun, 09 Feb 2025 15:50:26 -0800 Organization: None to speak of Lines: 35 Message-ID: <87bjvar83h.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 10 Feb 2025 00:50:30 +0100 (CET) Injection-Info: dont-email.me; posting-host="f4acd3ba793eeb2facf0b27d62bf5cd0"; logging-data="931369"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19x+UN5pLwGS+jYh+cYcJYs" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:ukAHk8k3qi4uaPH7+maw7XmlHTY= sha1:zYVI5icNKe7XZpMvhA07Xos+SwY= Bytes: 2012 Janis Papanagnou writes: [...] > I had other languages in mind.[*] > > Janis > > [*] For example Simula: > > begin > integer n; > n := inint; > begin > integer array arr (1:n); > arr(5) := 9; > end > end > > (Which is also understandable, since in Simula declarations must appear > before statements in any block.) Apparently Simula doesn't allow variables to be initialized in their declarations. Because of that, `n := inint;` (where inint is actually a call to a value-returning procedure) is a separate statement. If Simula supported C-style initializers, then presumably the inner block would not be needed: begin integer n := inint; integer array arr (1:n); arr(5) := 9; end -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */