Re: C90 penetration
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 27 Mar 2009 08:06:26 -0700
James Kuyper <jameskuyper@xxxxxxxxxxx> writes:
CBFalconer wrote:
jameskuyper wrote:
... snip ...
That wouldn't resolve the problem of:
double d = {"I am not a number, I am a free man!"};
If we agree on a set of digits that includes all Latin 1 alpha,
space, comma, and the digits from 0 through 9, and agree that
characters outside that set are to be discarded, the above can
represent a number in base 64. If we also allow the '!', and make
the ',' represent 'e' for exponents, the above also seems to be a
valid floating point value. :-)
You miss the point; if 'double' were indeed a typedef for a struct
containing a char array, then the above initialization would normally
be acceptable; however, according to the C standard, such code is a
constraint violation for which a diagnostic is required. The compiler
could disallow, or at least diagnose, such code as a special case, but
it would require special-case handling.
And there are a number of other reasons why making "double" a typedef
for a struct type would make a compiler non-conforming. Two examples:
"double" could be used as an ordinary identifier at block scope
(hiding the typedef), and "long double" would be a syntax error.
Of course a compiler could implement double as a struct, generating
either inline code or calls to library routines for various
operations, but the struct declaration would have to be hidden from
user code.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- C90 penetration
- From: kerravon
- Re: C90 penetration
- From: Eric Sosman
- Re: C90 penetration
- From: Stephen Sprunk
- Re: C90 penetration
- From: Jack Klein
- Re: C90 penetration
- From: Tristan Miller
- Re: C90 penetration
- From: kerravon
- Re: C90 penetration
- From: James Kuyper
- Re: C90 penetration
- From: kerravon
- Re: C90 penetration
- From: Ben Bacarisse
- Re: C90 penetration
- From: Keith Thompson
- Re: C90 penetration
- From: jameskuyper
- Re: C90 penetration
- From: CBFalconer
- Re: C90 penetration
- From: James Kuyper
- C90 penetration
- Prev by Date: Re: C as a scripting language
- Next by Date: Re: doubt with char array
- Previous by thread: Re: C90 penetration
- Next by thread: Re: C90 penetration
- Index(es):
Relevant Pages
|