Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: absence of max Date: Tue, 29 Nov 2016 12:54:34 -0800 Organization: None to speak of Lines: 58 Message-ID: References: <0e1db67d-0ab8-4971-a319-8aa66a40b873@googlegroups.com> <436aadfe-20e5-4349-bdf4-9bac145b0d7e@googlegroups.com> <878ts2h5uk.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a5363bb21fe375e056a99c05fd10e589"; logging-data="10660"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GOVSogQiY5afy/12ovdo6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:6QfkqgTfTCh7n3iUhFX+13BTaG0= sha1:85ZtjDdCT7PwVyrrinGJinw2x3w= Xref: csiph.com comp.lang.c:97746 BartC writes: > On 29/11/2016 19:29, Keith Thompson wrote: >> supercat@casperkitty.com writes: >>> On Tuesday, November 29, 2016 at 9:18:50 AM UTC-6, Richard Heathfield wrote: >>>> In C, "cast" means "explicit conversion". If you want to discuss your >>>> own language, take it up in a newsgroup devoted to that language. >>> >>> I like to use the phrase "explicit cast" in cases where casts are >>> intended to explicitly indicate, to "anything" reading the code >>> (compiler or human), that something "unusual" may be going on. >> [...] >> >> I like to use the word "cast" for that. > > The C Standard uses 'explicit cast' in 6.5.4p3 (2007 and 2009 drafts). The C90, C99, and C11 editions of the standard all use that phrase. (In C90 it's under Semantics; in C99 and C11 it's under Constraints.) > I wonder what they could possibly mean? It means the same thing as "cast". Presumably the authors chose to add the redundant word "explicit" for emphasis. I probably wouldn't have done so, but it's not wrong. Do you think that "explicit cast" means something different from "cast", in that context or any other C context? If so, what? For that matter, I'm fairly sure the entire sentence: Conversions that involve pointers, other than where permitted by the constraints of 6.5.16.1, shall be specified by means of an explicit cast. is redundant, since it's already covered by the constraints on simple assignment (which also apply to parameter passing, initialization, and return statements). A little redundancy isn't necessarily a bad thing (the C standard is not an entirely formal document), but in my opinion that particular sentence should be a footnote. My guess is that that wording was added to emphasize a change in the language. Looking back at the 1974 and 1975 versions of the C manual, I'm a bit surprised to see that the language didn't have a cast operator. K&R1 (1978) did, but it's not clear that a cast was required for pointer conversions. In old C, it was common to see things like char *ptr = 0xDEADBEEF; or, more likely for the PDP-11: char *ptr = 0177770; to allow references to a specific memory address. I think the wording was added to emphasize that things like that were no longer valid. -- 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"