Rethinking... (Re: RFC: fp printing speedup...)

Nathan Myers ncm-nospam@cantrip.org
Fri Nov 14 19:21:00 GMT 2003


On Fri, Nov 14, 2003 at 05:39:35PM +0100, Paolo Carlini wrote:
> Nathan Myers wrote:
> 
> >Any difference in behavior between the single-character and array
> >forms of facet members is a user error. If it doesn't say so
> >clearly enough in the standard, that's a Defect. Enter a Defect
> >Report on the subject. Mark 12988 as "not a bug", and reference
> >the DR.
> >
> >We're not obliged to make our library stupidly slow just because
> >the standard missed identifying, in detail, yet another way that
> >a user could do something obviously wrong.
> 
> Well, some observations:
>  1- The current standard is quite clear about the form of widen which
>     must be used.

Again, the "as-if" rule applies.  The standard text is meant to describe
precisely the semantics that must be satisfied for the resulting character.
How the implementation actually gets that character is an implementation 
detail.  Of course, actually calling widen(c) is one way.

>  2- As far as performance is concerned, the difference is really minimal
>     due to both caching and the memcopy thing I pointed out before.

Agreed, as already noted.

>  3- Therefore, wouldn't be more correct to implement first the standard
>     in force and only when the DR has reached the "Defect" status
>     implement the resolution? Usually, we proceed this way...

In principle, yes.  In cases like this, it would be needlessly pedantic
when the alternative seems more natural.  In practice, if it encourages
abuses such as defining a facet with different semantics for the two 
widen members, it's doing users a disservice.  In general, the earlier 
and more visibly that user errors result in failure, the better.

>  4- What does Martin think? He conceived the testcase, after all!

>  5- I'm aware of at least another popular and up to date implementation
>     using widen(char).

It's never surprising to find suboptimal code in any implementation.

>  6- The "pregnancy metaphor" seems to me really rude, wrt your usual
>     very high standards of quality.

I had to go back and re-read my message to figure out item 6.  The
expression "...allowed to erase your disk and impregnate your sister" 
is idiomatic standardese for undesirable but standard-conformant 
actions that may result from depending on undefined behavior.  It 
could seem rude on first encounter, but the vivid imagery has a 
purpose.  I apologize to everyone on the list for whom this idiom was 
not already familiar.

I want to make clear that my use of "stupidly" does not refer to any
gentle reader, but rather to the observable actions of the code itself.
I presume we have all written code that does things stupidly, for a 
variety of (perhaps temporarily) sound reasons.

Nathan Myers
ncm-nospam@cantrip.org



More information about the Libstdc++ mailing list