Sujet : Re: on allowing "int a" definition everywhere
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.cDate : 03. Sep 2024, 10:20:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240903122004.0000348e@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
On Tue, 3 Sep 2024 04:54:10 -0000 (UTC)
Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
On Mon, 2 Sep 2024 10:53:33 +0100, Bart wrote:
On 02/09/2024 04:32, Lawrence D'Oliveiro wrote:
On Tue, 27 Aug 2024 19:59:13 +0100, Bart wrote:
void draw_line(f32 x, y, x2, y2; u32 colour) {
>
- Allow shared types in parameter lists ...
A bit easier if you flip it around and use Pascal-style syntax:
procedure draw_line(x, y, x2, y2 : f32; colour : u32)
See how much more natural that is?
It becomes a bit less natural when you want to initialise a
variable at the same time, or want define a default value for a
parameter.
Pascal didn't allow either of those.
Ada does, with a very natural extension of the same syntax.
I didn't write Ada program for many years (although probably for less
years than you), but I regularly write VHDL, which syntax is heavily
inspired by Ada. My experience with it can in short be summarized as
"Bart is correct".
VHDL declaration + initialization syntax works not too badly as long as
you want to declare one signal (or constant or variable). It does not
work when you try to combine declaration of two signals of the same
type. It's so unnatural that I don't even know if it's at all allowed.
Now, Bart seems to think that ability to combine several declarations of
the same type is important. Here I disagree. At best, it's occasionally
nice.
Even
allows passing arguments by keyword, too.
By keyword? Do you mean call with named parameters association?
Note that even C++ has now had to allow function return types to be
specified at the end of the prototype instead of up front, because
type interdependencies don’t work very well otherwise.
Likely happened after I stopped following.