Sujet : Re: Reduction expressions
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.adaDate : 21. Aug 2024, 01:41:55
Autres entêtes
Organisation : None to speak of
Message-ID : <874j7edanw.fsf@nosuchdomain.example.com>
References : 1 2 3 4
User-Agent : Gnus/5.13 (Gnus v5.13)
Lawrence D'Oliveiro <
ldo@nz.invalid> writes:
[...]
I thought the difference was obvious. “subtype” is the C equivalent of
“typedef”, just giving a new name to an existing type. So
>
subtype A is B;
>
(where A and B are simple identifiers) is valid, whereas
>
type A is B;
>
is not: a “type” declaration always creates a new type: you have to write
at least
>
type A is new B;
>
and now you have two types with different names that are structurally the
same, but not compatible.
A subtype with no added constraint is similar to a C typedef, but given
subtype Digit is Integer range 0..9;
Digit is distinct from Integer (though they're both the same type).
C doesn't have anything directly corresponding to Ada subtypes.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */