Sujet : Re: Two questions on arrays with size defined by variables
De : noone (at) *nospam* noone.net (Andrey Tarasevich)
Groupes : comp.lang.cDate : 09. Feb 2025, 18:29:12
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <voaol9$o8ic$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On Sun 2/9/2025 9:19 AM, Janis Papanagnou wrote:
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.)
Well, in that case your previous mentions of "block context" are not related to VLAs at all. You apparently meant that in order to introduce a new declaration, any new declaration "in the middle of the code" one needs to open a new block - just because the language requires all declarations to reside at the beginning of a block.
This was the case in C90, where we also sometimes had to open new blocks to introduce new declarations. But starting from C99 this is no longer necessary. In C99 one can simply place declarations in the middle of the code "C++-style" (the underlying semantics is still different from C++, but syntactically/superficially it looks pretty much the same).
-- Best regards,Andrey