Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Non-(sub)-standard C |
| Date | 2015-05-23 14:38 -0700 |
| Organization | None to speak of |
| Message-ID | <87a8wvq8j8.fsf@kst-u.example.com> (permalink) |
| References | (2 earlier) <fb8563af-8a3c-496a-8c8f-c795ff468bea@googlegroups.com> <slrn3vfsmlsd2q.9vq.andrews@sdf.lonestar.org> <49b129ca-69c6-441c-a70c-3b8cdb5b63fc@googlegroups.com> <87mw0wqqb6.fsf@kst-u.example.com> <8e08366d-1809-48a2-b20c-22bb253961c3@googlegroups.com> |
David Kleinecke <dkleinecke@gmail.com> writes:
> On Friday, May 22, 2015 at 2:02:14 PM UTC-7, Keith Thompson wrote:
>> David Kleinecke <dkleinecke@gmail.com> writes:
>> [...]
>> > What you are largely saying is quite valid. But not, I fear, in the
>> > core C language. I would place such considerations in the optimizer.
>> > I would allow the optimizer to inline whatever makes sense (like a
>> > static function called only once).
>>
>> That's a meaningless distinction. An optimizer is part of the
>> implementation. It must follow the rules specified by the language
>> standard.
>>
>> The standard, at least in the case of C, specifies the behavior of a
>> running C program. Optimization rearranges the generated code in a way
>> that doesn't change that behavior, or at least keeps it within the range
>> of permitted behaviors.
>>
>> > The optimizer should have at least two stages - one for optimizations
>> > that are target machine independent and another for machine dependent
>> > re-arrangments. Optimization is a big subject and hard to generalize
>> > about.
>>
>> That's an implementation detail, not relevant to the language
>> definition.
>>
>> > The core C language implies a rather simple abstract machine.
>>
>> Yes, and an implementation can implement that abstract machine any way
>> it likes, as long as it preserves the required behavior.
>
> I remain only marginally interested in the standards - I am interested
> in the C language - not in the particular use of it described in the
> standards. It is convenient for me to accept Part 6 of the C90 standard
> rather than K&R as the definition of the C language - but I am prepared
> to disagree if I feel it is suitable.
As C99 and C11 catch on, you might find it less convenient to ignore
everything after C90. If you see `for (int i = 0; i < N; i ++)`,
I suggest it's to your advantage to recognize it as something other
than a syntax error.
I think of the standard as a (proposed) contract between implementers
and programmers. If an implementation follows the standard, I as a
programmer can depend on my programs to behave correctly if I also
follow the standard.
Unless you write your own compiler and library that conform only
with the parts of the standard that you like, I'm not sure what
the point of your disagreement is.
I doubt that anybody familiar with the standard thinks it's
completely ideal; we all have parts we would prefer were different.
> For example, I disparage the "register" storage class specifier because
> it does something (when it does anything) better done by the optimizer.
Most of us agree. The standard merely requires compilers to recognize
it and, for example, diagnose any attempt to take the address of a
register-qualified object. It was probably useful when it was
introduced to the language back in the 1970s. But removing it from the
language now would break existing code for no great benefit. (The use
of "register" is unchanged from C90 to C99 and C11.)
We teach new C programmers not to bother using it and move on. It's
arguably a flaw, but it's trivial.
> I don't know whether the newer standards keep "auto" but in any case I
> doubt that it is ever given any meaning,
It does have a meaning: it specifies that an object has
automatic storage duration). But it's permitted only in contexts
where the object would have automatic storage duration anyway.
Some programmers might use it for emphasis. Like register, it was
useful when it was first introduced. At the time, objects could be
defined without specifying their type, which would default to int, so
auto i;
at block scope was equivalent to the modern
int i;
BCPL, one of C's predecessors, was more or less typeless; I believe
"auto" was necessary.
Like "register", removing "auto" from the language would break some
existing code, and keeping it has trivial cost. We teach new C
programmers not to bother using it and move on.
The use of "auto" is unchanged across C90, C99, and C11. C++11 has
dropped the original meaning and given it a new one.
If you want a language that's free of features that exist only for
backward compatibility, perhaps C is not the language for you.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
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"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-20 08:56 -0700
Re: Non-(sub)-standard C Noob <root@127.0.0.1> - 2015-05-20 18:02 +0200
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-20 09:20 -0700
Re: Non-(sub)-standard C Les Cargill <lcargill99@comcast.com> - 2015-05-20 12:12 -0500
Re: Non-(sub)-standard C Keith Thompson <kst-u@mib.org> - 2015-05-20 10:53 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-21 09:44 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-21 10:22 -0700
Re: Non-(sub)-standard C Keith Thompson <kst-u@mib.org> - 2015-05-21 10:46 -0700
Re: Non-(sub)-standard C Andrew Smallshaw <andrews@sdf.lonestar.org> - 2015-05-21 19:39 +0000
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-22 10:13 -0700
Re: Non-(sub)-standard C Keith Thompson <kst-u@mib.org> - 2015-05-22 14:02 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-23 09:41 -0700
Re: Non-(sub)-standard C Robert Wessel <robertwessel2@yahoo.com> - 2015-05-23 13:37 -0500
Re: Non-(sub)-standard C Keith Thompson <kst-u@mib.org> - 2015-05-23 14:38 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-24 10:10 -0700
Re: Non-(sub)-standard C wpihughes@gmail.com - 2015-05-24 12:53 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-24 13:05 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-25 09:01 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-25 10:19 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-26 11:01 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-26 11:40 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-27 10:28 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-27 11:13 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-28 12:20 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-28 12:26 -0700
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-29 10:12 -0700
Re: Non-(sub)-standard C wpihughes@gmail.com - 2015-05-29 13:57 -0700
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-26 11:33 -0700
Re: Non-(sub)-standard C Keith Thompson <kst-u@mib.org> - 2015-05-24 14:03 -0700
Re: Non-(sub)-standard C Richard Heathfield <rjh@cpax.org.uk> - 2015-05-24 22:09 +0100
Re: Non-(sub)-standard C Ian Collins <ian-news@hotmail.com> - 2015-05-25 16:46 +1200
Re: Non-(sub)-standard C James Kuyper <jameskuyper@verizon.net> - 2015-05-25 00:55 -0400
Re: Non-(sub)-standard C Ian Collins <ian-news@hotmail.com> - 2015-05-25 18:08 +1200
Re: Non-(sub)-standard C Richard Heathfield <rjh@cpax.org.uk> - 2015-05-25 10:58 +0100
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-25 09:12 -0700
Re: Non-(sub)-standard C James Kuyper <jameskuyper@verizon.net> - 2015-05-25 18:40 -0400
Re: Non-(sub)-standard C Ian Collins <ian-news@hotmail.com> - 2015-05-26 11:14 +1200
Re: Non-(sub)-standard C rick.c.hodgin@gmail.com - 2015-05-25 19:01 -0700
Re: Non-(sub)-standard C James Kuyper <jameskuyper@verizon.net> - 2015-05-25 22:03 -0400
Re: Non-(sub)-standard C Richard Heathfield <rjh@cpax.org.uk> - 2015-05-25 10:40 +0100
Re: Non-(sub)-standard C Ian Collins <ian-news@hotmail.com> - 2015-05-25 22:50 +1200
Re: Non-(sub)-standard C David Brown <david.brown@hesbynett.no> - 2015-05-25 12:42 +0200
Re: Non-(sub)-standard C James Kuyper <jameskuyper@verizon.net> - 2015-05-25 19:00 -0400
Re: Non-(sub)-standard C David Brown <david.brown@hesbynett.no> - 2015-05-26 08:43 +0200
Re: Non-(sub)-standard C David Kleinecke <dkleinecke@gmail.com> - 2015-05-25 09:07 -0700
Non-(sub)-standard C Chad <cdalten@gmail.com> - 2015-05-20 19:27 -0700
csiph-web