Liste des Groupes | Revenir à cl c |
On 10.02.2025 00:50, Keith Thompson wrote:Janis Papanagnou <janis_papanagnou+ng@hotmail.com> 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.
The Cim compiler I use actually supports a constant initialization -
but I'm positive this is non-standard! - like
begin
integer n = 10;
integer array arr (1:n);
arr(5) := 9;
end
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:
Indeed. (See non-standard example above.)
>
begin
integer n := inint;
integer array arr (1:n);
arr(5) := 9;
end
>
This is not possible because 'n' isn't a constant here (and 'inint' is
a function, as you say). - So you're correct that the block would not
be an inherent necessity for that declaration [with Cim compiler].
A general statement for the standard Simula language cannot be given,
though, since it's undefined.
Janis
Les messages affichés proviennent d'usenet.