[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: Clause 10, Expression Evaluation
On Thu, 12 Jul 2007 16:16:03 +0900, Guillaume Melquiond
<guillaume.melquiond@xxxxxxxxxxx> wrote:
Le jeudi 12 juillet 2007 à 03:15 +0100, Malcolm Cohen a écrit :
. the formats of parameters to generic and non-generic functions,
What's this "generic" vs "non-generic" of which you speak?
Fortran's had generic intrinsics for 30 years, and generic user functions
for 16 years, but the bullet point makes absolutely no sense whatsoever
in their regard.
It doesn't make sense for C either. C doesn't have generic functions
(at least, the C99 standard doesn't have anything it calls generic
functions,
though it does have "type-generic macros").
In some languages, they are called polymorphic functions.
Bah humbug. Not in any sensible language they're not.
They are
functions that do not force the type of their arguments, but instead the
precise functions are selected by looking at the type of their
arguments.
So you say, but you are not the author of the paper, and ...
...the bullet point doesn't make sense for that interpretation,
there not being any such thing as a concrete "generic function"
separate from the mere collection of its specifics...
...which is already covered by the mere word "function".
I did think I adequately explained it in my original message.
In C, operator + is such a "generic function":
No, + is an operator (and causes an operation to be performed),
not a function. It's not called a function in C, in Fortran,
in IEEE 754, ... the word "function" has a specific technical
meaning.
the operation
that is invoked is not the same whether you type 1+2 or 1.+2.
I don't think we're shedding light on my complaint about poor or dubious
use of terminology by using it in an even vaguer manner.
. the formats of results of generic functions
The "format" of the result of an ordinary function is considered to be
outwith the scope of the Fortran standard. To my mind it's inherently
outwith the scope of a language standard, since it's a "physical property"
that has nothing to do with the language as such.
You have to read "format" with the 754R meaning (see the glossary)
And just how can I do that since I'm not on the secret committee?
(As I already said at the start.) Sure I have the last public version,
but there appears to have been many widespread changes in the secret
version.
, that
is: single-precision format, double-precision format, and extended
format.
I know that perfectly well.
Translated into a programming language wording, it can usually
be read as the "type" of a floating-point number.
No it most certainly cannot.
As far as I know,
there is no useful language in which you cannot guess whether a function
returns a single-precision number or a double-precision number.
And that says ALMOST NOTHING about the "format".
So it is not outside the scope of a language.
Contrariwise. The format is a physical property of the representation
of the values of the type. That does not, in fact, have any necessary
connection at the language level.
For the languages I know of, when you perform the addition of two
double-precision numbers and then convert the result to a
single-precision number, you can usually tell from the language
standards how many formats are involved and hence how many roundings are
supposed to happen.
Not true for many languages.
Lots don't even define that level.
Others explicitly avoid that level or exclude it from standardisation.
Note that it does not mean the compiled program will
behave as mandated,
Most languages don't have this level of "mandate".
but this is a matter of having a compliant compiler or not.
Not so. Speaking as a standard writer, language designer and
language implementor (and occasional language user too!),
I am quite familiar with the concept of standard compliance.
I have never used Fortran and I only have the F77 standard at hand. But
looking at section 6.1.4, it seems you can predict which formats are
involved in a parenthesized expression. Am I wrong?
Yes. For one thing, Fortran establishes the meaning of the whole
expression; it does not specify how the value is computed.(*) For another,
you need to look at the SCOPE and EXCLUSIONS right at the front of the
standard: the "physical properties of the representation of quantities
and the method of rounding, approximating, or computing numeric values
on a particular processor" are excluded from the standard (text quoted
from the current standard).
(*) Yes, the semantics are described recursively, but the processor is
not constrained to compute the value in that way.
BTW, there have been 3 revisions of Fortran since 1977 (30 years ago!),
and work is underway on a fourth. If we are going to debate what the
Fortran standard says/means, something more recent would be appropriate.
If you're interested you can download various working drafts from
about F95 onwards.
Cheers,
--
Malcolm Cohen, Nihon Numerical Algorithms Group KK, Tokyo, Japan.