Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C++ features for C Date: Tue, 15 May 2018 13:15:46 -0700 Organization: None to speak of Lines: 68 Message-ID: References: <11edbfd7-461d-4579-8ac7-a9e84a6b7630@googlegroups.com> <7b110d3e-ddb5-42a0-af99-aa5b0cb30832@googlegroups.com> <13efc313-d10c-4357-9aa7-6fa55b09d948@googlegroups.com> <87po1xi2n1.fsf@bsb.me.uk> <87k1s5hror.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="fd2ef88f3973fbdcdd5cf6f7f328cfd4"; logging-data="3822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F7M53QGFQ0BApn5iBHb+6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:w+EAPq8FGx2f+wJZNRddRyI+syw= sha1:4XP5RuzaKeBV6G+JKOxNliK+Yg4= Xref: csiph.com comp.lang.c:130626 bartc writes: > On 15/05/2018 20:56, Keith Thompson wrote: >> bartc writes: >>> On 15/05/2018 19:59, Keith Thompson wrote: >>>> bartc writes: >>>>> Why isn't it C? You make it sound like having a third character type is >>>>> a really big deal. >>>> >>>> It isn't C because C has three distinct character types. I never said >>>> it was a "really big deal", just that it's how the language is defined. >>> >>>> I'm not asking you to care about these facts, just to stop pretending >>>> you don't know them. >>> >>> I didn't know about the third kind of char until recently. I thought it >>> was too silly an idea to implement. I also thought that a type called >>> 'char' needs to be unsigned. >>> >>> So I implemented a C where a 'char' type is synonymous with 'unsigned char'. >>> >>> If that's non-conforming, then it's too bad. I believe this modification >>> get rids of some baggage that no one really needs any more. >> >> Then you have implemented something similar to C. You have not >> implemented C as defined by the standard. (And, as it happens, >> you have not implemented anything that I care about.) >> >> You are, of course, free to do exactly that. But again, I'll ask >> you, at least when posting to comp.lang.c, to make it clear when >> you're talking about your personal almost-C language and when you're >> talking about the actual C language as defined by the ISO C standard. > > What are the practical implications of not having a distinct third > character type? > > What programs will I not be able to write? Which ones will I not be able > to compile? Ok, let's assume an otherwise conforming C compiler which treates `char` and `unsigned char` as the same type. This conforming program would fail to compile: #include int main(void) { printf("\"abc\"[0] is of type %s\n", _Generic("abc"[0], char: "char", unsigned char: "unsigned char", signed char: "signed char")); } I admit that's a bit contrived, but I can imagine similar constructs being useful. A more likely problem is that someone using such a compiler would write code that would compile and run, and later find that it's rejected by some other compiler. For example: unsigned char *data = "abcd"; which is a constraint violation in standard C. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"