Sujet : Re: remark on defining size of basic types
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.cDate : 05. Apr 2024, 01:46:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uunhls$vbtu$2@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Fri, 5 Apr 2024 02:25:22 +0200, Janis Papanagnou wrote:
On 05.04.2024 01:38, Lawrence D'Oliveiro wrote:
>
On Thu, 4 Apr 2024 15:15:26 +0200, Janis Papanagnou wrote:
Sometimes it's useful to have an unbounded or parameterized integral
data type available ...
Interestingly, Fortran (of all things) has that.
Was that the e.g. '*8' syntax? - Did it allow arbitrary lengths?
No, and no. Since Fortran 2003, you can parameterize a custom type
definition with integer values. These can be used to specify the sizes of
arrays, or they can be used as codes for the different (implementation-
defined) precisions of integer and real types. An example from the
language spec:
TYPE :: t1(k1,k2)
INTEGER, KIND :: k1,k2
REAL(k1) a(k2)
END TYPE
This defines a custom type “t1”, which is an array of reals; the first
parameter determines the precision of the reals, and the second one
specifies the length of the array.
There are various query mechanisms (built-in functions, standard modules)
to determine the valid values of the number-precision codes.