Am Mi., 28. Aug. 2024 um 18:59 Uhr schrieb Will Clinger <xxxxxx@larcenists.org>:
On Wed, Aug 28, 2024, at 8:27 AM, Marc Nieper-Wißkirchen wrote:
> If those "loopholes" are interpreted in the way you do here, what is
> the actual meaning of x|p then?  Adding an explicit mantissa width
> becomes somewhat meaningless when an implementation is allowed to
> ignore it in any case.

You appear to be assuming there is some objective "actual meaning
of x|p".  In my opinion, the purpose and specification of that notation
has never been defined so well as to create an objectively actual
meaning.

Yes, I assume that there is an objective actual meaning. If there is a sensible reading of a text that gives the things it talks about well-defined meanings, it is preferable to an alternative reading that makes things ill-defined.

The reason for that is simple.  English, like every natural language, is inherently imprecise.  There will always be different readings of one text, and the common denominator of all possible readings will probably be empty.  Thus, readings that are self-consistent and minimise meaningless sentences are preferable.

In case of doubt, I believe that the writers' intentions matter, for otherwise, the meaning of a text would contain too many artefacts of the language used to write it that should not matter for the scope of the text.

 
> Moreover, interpreting those loopholes in that way seems to confound
> the meaning of the various exponent marks (s, f, d, l) with the meaning
> of the explicit mantissa width.

The meanings of those exponent markers are implementation-dependent
as well, but it seems to me their meanings are more well-defined than the
meaning of the x|p notation.

You write that the meanings [...] are implementation-defined as well, but it nowhere says that the meaning of "|p" is implementation-defined.
 
> Maybe we can simplify the discussion by looking at exact numbers where
> any machine floating point representation does not play a role.
>
> The sentence
>
> "A representation of a number object with nonempty mantissa width, x
> |p, represents the best binary floating-point approximation of x using
> a p-bit significant."
>
> from R6RS implies that
>
> #e0.1|1
>
> denotes the number 1/8.  (And applying the inexact procedure to that
> number gives 0.125 regardless of any specific machine floating-point
> format.)

I disagree with your interpretation.  It seems to me that "the best binary
floating-point approximation of x" will depend upon specifics of the
floating-point system adopted by an implementation,

An implementation does not have to use a binary floating-point format to internally represent inexact numbers.  Thus, "the best binary floating-point approximation of x" in that context can only mean the mathematical notion, not any machine-specific one.
 
and that the sentence as written gives priority to that implementation-dependent choice of floating
point approximations ahead of the "using a p-bit [significand]" phrase, which
appears to me to have been an unsuccessful attempt to add some too-little,
too-late qualification to the implementation-dependent choice of floating point
that has already been implied by the phrase that precedes it.

 
> Chez Scheme, however, evaluates #e0.1|1 to 1/10.

One could argue that is a bug.  On the other hand, one could argue that
pretending it is possible to convert an ambiguous and poorly specified
notation such as 0.1|1 into an unambiguous and well-specified notation
by prefixing it with #e is folly.  The #e can't undo the ambiguity and poor
specification of a notation that follows it.

My point is that there is a reading of SRFI 77/R6RS that gives x|p an unambiguous and well-specified meaning; one just has to take the sentence

"A representation of a number object with nonempty mantissa width, x |p, represents the best binary floating-point approximation of x using a p-bit significant."

literally as Mike does.  I would see a problem if there were a different, sensible reading that would also give x|p an unambiguous and well-specified meaning, but that would differ from the above meaning.
 
In summary, I think the x|p notation is a classic example of how attempts
to over-specify relatively unimportant corner cases for the purpose of
improving compatibility between implementations often create even more
opportunities for incompatibility between implementations.  If not for the
existence of the x|p notation, someone who wants to write the number 1/8
would simply write 1/8 or #e0.125 or .125 (depending on the desired property
of exactness), and there would be no question as to what is meant.

The syntax 0.1|1 is, of course, a silly example.  In practice, these things matter when data written by a system with, say, IEEE single precision, is read by a system with IEEE double precision.  The written external representations would be like 1.1|24; if the reading system ignored the mantissa width, it would fabricate binary digits that have never been there.

And having a way to describe the number of meaningful binary digits in a number literal makes a lot of sense to me.

But you invented the lexical syntax in SRFI 77, didn't you?  So why do you seem to renounce it now?  What changed since you wrote that text?

Thanks,

Marc