[std-interval] Comments on the Interval Standard Proposal
Lawrence Crowl
lawrence.crowl at gmail.com
Mon Sep 25 22:27:54 PDT 2006
My comments are based on 2006-09-05 revision 1.
III Impact on the Standard
paragraph 3: "however, are necessary" => "however, are not necessary"
26.6 Interval Numbers
paragraph 2: Remove bool.
This text is a holdover from an earlier version of the proposal.
26.6.1 Header <interval> synopsis
Might be better to change the namespace from X_ops to X_comparisons?
Such a change is more in line with the actual content.
26.6.2 interval class template
The standard doesn't actually need to provide a definition of the template
class interval. That is, the specializations can be defined without a
definition for the template. Is there a particular reason for
defining the
template?
26.6.4 interval member functions
whole();
I do not see a definition of the static member function whole().
I am particularly interested in what whole().lower() et.al. means.
interval(const char *s);
I think undefined behavior here is a very bad idea. The programmer
cannot effectively avoid the bad behavior without parsing the string
manually. That is too much of a burden. I suggest that the parse
either return empty (which is indistinguishable from a successfully
parsed empty) or return an error code, or throw an exception. You
should ask the library experts for their prefered solution.
interval(T t);
What does "if the value of t is infinite, it will be interpreted
as a finite
number to [sic] big to be representable when constructing the
interval" mean? How does this statement affect my program?
interval(T lo, T hi);
The undefined behavior here is almost zero cost to avoid. In particular,
under IEEE 754, the comparison <= returns false when either of its
operands are NaN. The only cases that fail are interval(-oo,-oo) and
interval(oo,oo). Assuming that the extra two comparsions to detect
these cases are too expensive, what are the consequences of defining
these two intervals to be valid? (Remember, I am a language/compiler
person, not an interval person.)
template<class U> interval(U x);
I think the prefered form is template<typename U> ....
What is the rationale for this template? There isn't a corresponding
definition in the specializations.
If the definition is to remain, the constraints on U need to be specified.
26.6.7 bool_set comparisons
template< class T> bool_set operator<=(....
The definition confused me greatly. I spent quite a bit of time trying
to decide whether or not a<=b was the same as (a<b)|(a==b).
Eventually, I decided that it was. However, the definition certainly
didn't lead one to easily conclude that they were the same. I think
the proposal would be clearer if the "or" version of the definition were
used, particularly for those of us that know a<=b is not always the
same as !(b>a).
26.6.10 Set inclusion comparisons
template< class T> bool operator<(....
template< class T> bool operator<=(....
I think the 'returns' clause has the order of arguments to the
'contains' function reversed.
On Infinity and NaN.
I think the proposal might be substantially improved by recognizing
two categories of implementation -- those with infinity/NaN values
in their floating-point, and those without. The second would have
degraded semantics. The standard probably needs needs a macro
indicating the category.
--
Lawrence Crowl
More information about the Std-interval
mailing list