asctime.c

Clive D.W. Feather clive at demon.net
Thu Aug 5 06:38:17 UTC 2004


Robert Elz said:
> Clive D.W. Feather <clive at demon.net> said:
>   | > You'd prefer years with leading zeroes?   Why?
>   | Because that's what "constant width" says to me. 
> 
> Hmm, one of us is confused.   A constant width field to me is one with
> a fixed width (fixed number of bytes used).   That by itself says nothing
> about the characters that get put in the field.

Okay.

However, I'd rather that the year field said "0097" and not "  97", so that
some idiot doesn't think the latter means 1997.

> clive at demon.net said:
>   | I don't believe you can write any code that that statement is true for.
[...]
> Programs that fail to compile (or link) aren't a serious problem, they're
> fixable.   The problems are programs that seem to work just fine, but then
> (just sometimes) don't produce the results they're supposed to produce.

Even with that limitation you have problems. There were just too many
places where pre-Standard compilers differed and the Standard had to make a
choice one way or the other.

> But providing something
> different than what programs have been expecting, with no way for the
> program to discover that it isn't going to get on this system the
> same behaviour as on all the others, essentially forever, is seriously poor,
> and is the very thing that standards are supposed to help prevent, not
> promulgate.

While asctime() may not be a good example, this is a situation that the
authors of C89 had to face time and time again, and *had* to come down on
one side or the other of various decisions. A good example is:

    if (-1 > (unsigned short) 0)

which was true on some implementations but became false when that
implementation moved to C89.

-- 
Clive D.W. Feather  | Work:  <clive at demon.net>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <clive at davros.org>  | Fax:    +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
Thus plc            |                            |



More information about the tz mailing list