Article View: comp.lang.c
Article #1995Re: C and its peasant 'ancestors'
From: Dan Cross
Date: Mon, 30 Nov 2026 04:24
Date: Mon, 30 Nov 2026 04:24
87 lines
4131 bytes
4131 bytes
In article <11eio9n$28j2$1@kst.eternal-september.org>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>cross@spitfire.i.gajendra.net (Dan Cross) writes:
>[...]
>> To be provocative, I think it is easier to conceptualize if one
>> thinks of C as lacking first-class array types. Rather, C has
>> pointers to contiguous regions of memory of some size; the
>> array-like notation is just syntactic sugar around this.
>
>This could lead to a lengthy discussion about what "first-class"
>means. I'm not sure I want to participate in it.
>
>My point of view is that C very definitely has array types, array
>objects, array expressions, even array values. (A "value" is the
>"precise meaning of the contents of an object when interpreted as
>having a specific type". An array value consists of the values
>of its elements.)
Certainly, that's a valid viewpoint. But consider this:
struct A {
char a[10];
};
struct A foo(void) { return (struct A){ .a = " ... " }; }
char *bar(void) { return " ... "; }
There's no way to "return" an array from a function. Unless the
array is embedded in a `struct`. :-/
>It just restricts certain operations on array
>types/objects/expressions/values.
Well, that's precisely what it means not to be first-class, no?
>My preference is to think about C as it's currently defined. It's
>certainly important to understand where C's quirks came from, but
>dmr and WG14 went to a great deal of effort to define C in its own
>internally consistent terms. Understanding B certainly helps, but
>it shouldn't be *necessary*.
Indeed, it is not strictly necessary. But if one wants to know
_why_ C is the way that it is, it helps to know the history,
including the pecularities of the languages leading up to it,
and that were major influences on its design.
In this case, I brought up the pecularity of adding a number to
a string yielding a pointer as an example of weak typing; I
think it fair to say that most of the people participating here
know _what_ is happening there (you yourself wrote about it a
couple of responses ago), but explaining what is going on was
beside the point.
Perhaps a better example might have been something like this:
struct foo {
int a;
int b;
char *p;
};
struct foo foo[0x100] = { ... };
void *ptr = foo + 'A';
Of course we can explain _what_ is going on here: 'A' is an
integer type with some value (on my system, 0x41), and the
unadorned `foo` in the assignment decays to a pointer, and we
can certainly assign that to a `void *`, so we are just doing
pointer arithmetic; I can even think of valid reasons why one
might do exactly this. But it is precisely the sort of thing
that weakly typed languages let you do.
>> Btw, in the Q&A transcript at the above link, Ritchie says this
>> when asked about C declaration syntax:
>>
>> |It was Ravi Sethi who observed that if C's unary star operator
>> |were a postfix operator instead of a prefix operator, suddenly
>> |everything becomes nice and linear and clear.
>>
>> (Now excuse me, I am ducking and running for cover....)
>
>Ah, what might have been.
The one that got away.
- Dan C.
Technical Details
Message-ID:
<11eitqh$1t2$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<11dup6q$v4j9$1@dont-email.me> <11eij2a$hq5$1@kst.eternal-september.org> <11eimr1$4c3$1@reader2.panix.com> <11eio9n$28j2$1@kst.eternal-september.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c Subject: Re: C and its peasant 'ancestors' Date: Mon, 30 Nov 2026 04:24:49 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11eitqh$1t2$1@reader2.panix.com> References: <11dup6q$v4j9$1@dont-email.me> <11eij2a$hq5$1@kst.eternal-september.org> <11eimr1$4c3$1@reader2.panix.com> <11eio9n$28j2$1@kst.eternal-september.org> Injection-Date: Mon, 30 Nov 2026 04:24:49 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="1954"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)