> Date: Tue, 09 Mar 2004 14:34:45 -0800 > From: [log in to unmask] > James Giles wrote: > > > [log in to unmask] wrote: > > ... > > > OTOH, we could extend the syntax of the kind thing-o in a literal to > > > allow initialization expressions instead of names. One could then write > > > something such as 0.1_real_kinds(1) to get default real and > > > 0.1_real_kinds(2) to get double precision. > > > > I really dislike that one. This thread began with the observation > > that literals with KIND specifiers are illegible and error-prone > > and now has lead to an extension of that very feature which is less > > legible and more error-prone. Tragic irony? > > The key word is ALLOW. Notice it doesn't say REQUIRE. > > Maybe the middle part of the discussion got lost. Follow the chain of > logic and say where it went off the rails: If a provision is made to > specify the kind of literal constants that aren't decorated with a kind > specifier, how do you then get default kind? In 04-121 Dan proposed > arrays of kind parameters in ISO_FORTRAN_ENV for logical and character > kinds. This is trivial and clearly useful. An obvious generalization is > to provide such arrays for all kinds. An obvious provision is that the > (1) element in each array is the default kind. To get the default kind > for a literal, as opposed to what-you-get-if-you-don't-say-anything, there > are at least three solutions that start with Dan's reasonable and useful > proposal: > > 1. The standard also specifies scalar named constants for the four default > kinds (and for double precision real) in ISO_FORTRAN_ENV, > 2. The standard allows initialization expressions for kind specifiers in > literals (actually, <primary> would be better), or > 3. Expect the user to invent scalar names and give them values in named- > constant declarations. > > I don't like #1 because I don't like duplication. I prefer generalization. > Between #2 and #3, I prefer #2. Consider: > > use ISO_FORTRAN_ENV, only: REAL_KINDS > x = 0.1_real_kinds(1) > > or > > use ISO_FORTRAN_ENV, only: REAL_KINDS > integer, parameter :: DRK = real_kinds(1) > x = 0.1_drk What's wrong with 1.0 for default real, 1.0d0 for double precision, and 1.0q0 for extended or quad precision? No "_dp" etc addendum required. Then if you really want default real constants (and/or other precision constants) to have a given user-defined kind, give it via "_dp" etc. > -- > Van Snyder