Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.misc > #2202
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.misc |
| Subject | Re: A good subset of C |
| Date | 2014-05-06 00:42 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <lk97lp$bkq$1@dont-email.me> (permalink) |
| References | <lk7flm$m95$1@dont-email.me> <lk8qjv$ejd$1@dont-email.me> <op.xfer8g1j6zenlw@localhost> |
"Rod Pemberton" <dont_use_email@xnothavet.cqm> wrote in message
news:op.xfer8g1j6zenlw@localhost...
> On Mon, 05 May 2014 15:59:26 -0400, James Harris
> <james.harris.1@gmail.com> wrote:
>
>> Here's an attempt at this.
>>
>> * Separate compilation
>
> ?
>
> If it can compile one file, then it can compile many ... (?)
> I'd think this is, perhaps, a linking issue?
C supports separate compilation by, in part, using header files to convey
information between modules. For example,
#include "mod.h"
mod_func(MOD_OPER);
Here MOD_OPER is a constant defined in mod.h. Without the header the
compiler would not know what value to substitute for MOD_OPER. Neither would
it know the types of arguments to mod_func().
There are more-complex examples but that hopefully illustrates the kind of
thing I mean when I say that C supports separate compilation.
...
>> * Being able to choose integers of explicit sizes, e.g. uint16_t
>
> You only need two. (8-bits char, something bigger)
Not so. Say you were writing an x86 OS - something you are familiar with.
You would have 8-bit (many), 16-bit (e.g. port numbers), 32-bit (many) and
64-bit (e.g. TSC, MSRs) values to deal with.
>> * Enumerated integers
>
> Why? Enums are one of the least used aspects of C, IMO.
IYO or IYE? :-) They can be used instead of many #defines and automatically
allocate numbers. They would also be easy to compile so ISTM they would be
good to include.
>> * Structs
>
> Yes.
>
> No typedefs? They don't allocate space. I.e., good for overlaying
> data structures onto "arrays" of char, e.g., databases, records,
> filesystems, struct nodes in a linked list, etc.
Don't forget a typedef is just an alias for something that already exists.
Consider
struct Tag { ... };
No typedef but, here, the struct needs no space allocation. It is just a
definition and Tag is just a name.
...
>> * Support for variadic functions
>
> Why? Support a maximum of six parameters to start. If you're using
> more than three per function, you're doing something wrong anyway, IMO.
It is true that variadic support isn't often needed but when it is it can be
invaluable.
>> * Choice of where to place variables: stack, block, module
>
> Why?
>
> (That kind of defeats the purpose of C. Use Forth for that.)
Consider
int a;
void fn() {
int b;
static int c;
for (int d;;) {
}
for (int e;;) {
}
}
Here the intention is that A has module scope and storage, B has stack
storage, C has module storage but function scope, and D has block scope and
probably some form of stack storage but would not have to compete with E. D
and E could occupy the same stack space.
...
>> * ++ and -- operators
>
> What? No other operators? No assignment?
>
> What about logical and bitwise operations? && !! ~ | & ^
Sure, I just listed things which I thought were especially characteristic of
C.
...
>> By the way, I noticed that in a list of essential parts of C no
>> one mentioned bit fields. :-)
>
> Well, years ago, they warned that using bit-fields on some C compilers
> were broken, or perhaps they had endian issues or somesuch. So, the
> "C way" became #define masks and logical-and, e.g.,
>
> #define FLAG1 0x01
> #define FLAG2 0x02
> #define FLAG3 0x04
> #define FLAG4 0x08
>
> if(value&FLAG4) {
> ...
>
> If bit-fields worked, that would be the perfect place to use them.
>
> You do recognize C code like that, yes? I sure hope so... :-)
Yes, I once wrote up a note on this. See
http://codewiki.wikispaces.com/bitfield_operations.c
C's bit fields are notorious for being limited - which is why I put the
smiley!
James
Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 08:47 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 10:56 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 19:41 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 21:08 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 21:58 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 22:55 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-06 00:01 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 00:44 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 09:45 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 07:33 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 19:14 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 20:12 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:57 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 11:55 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-07 19:04 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 10:14 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-08 07:35 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 16:22 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-09 16:45 -0400
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-10 09:04 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-10 16:30 -0400
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-11 11:59 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-11 11:06 -0400
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-12 00:26 +0000
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-12 09:54 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-12 20:01 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-14 17:45 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-14 18:11 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-14 23:54 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-14 19:43 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 18:00 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-17 16:00 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 22:17 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-17 19:58 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-18 07:59 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-18 13:10 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-19 00:54 +0100
Re: A good subset of C Andy Walker <news@cuboid.co.uk> - 2014-05-15 01:31 +0100
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-14 23:43 -0500
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 18:38 +0100
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 11:04 +1200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-24 20:36 -0400
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 12:53 +1200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-24 21:34 -0400
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 14:11 +1200
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-25 06:47 +0000
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-25 06:43 +0000
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 20:59 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 22:28 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:57 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 00:26 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-06 14:21 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 15:43 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-07 16:03 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-07 21:31 +0100
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-07 15:41 -0500
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:46 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-06 00:42 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-06 06:48 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 15:40 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-08 06:50 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 15:43 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-08 14:41 -0400
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-05 19:08 -0500
csiph-web