Sujet : Re: on allowing "int a" definition everywhere
De : bc (at) *nospam* freeuk.com (Bart)
Groupes : comp.lang.cDate : 02. Sep 2024, 10:53:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vb41ut$1gbbm$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla Thunderbird
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. Current languages that use 'var x:T' style tend to put such an expression after the type: 'var x:T = expr'.
That's ugly and unwieldy (with the type spec slap in the middle), becoming even more so when declaring several variables with the same type: where do those expressions go?