Article View: comp.lang.c
Article #2009Re: C and its peasant 'ancestors'
From: David Brown
Date: Mon, 30 Nov 2026 09:25
Date: Mon, 30 Nov 2026 09:25
74 lines
4615 bytes
4615 bytes
On 30/11/2026 05:24, Dan Cross wrote:
> 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?
>
I'd agree with that definition.
In C, you can wrap data in a struct (or a union) and you now have a
strong type. There are no implicit conversions between different struct
types, or pointers to them - that is as strong as it gets.
Discussions about "strongly" and "weakly" typed languages often face
three problems (some of which have been pointed out before - and I am
not referring to any particular person here!).
First, people sometimes misunderstand the distinction between static
versus dynamic typing and strong versus weak typing.
Second, people often think, or at least write as though they think, that
these things are binary choices. Someone might say "Python is strongly
typed, C is weakly typed". Yet the above example of "struct A" shows
that you can use strong types in C. Allowing "123" + 2 as a valid
expression is seen as an example of why C is called "weakly typed" - yet
Python allows you to write "123" * 2 while still being called "strongly
typed". Even static or dynamic typing is not a binary choice - consider
runtime polymorphism in C++.
Thirdly, people often seem to think that weak versus strong typing is a
scale - an "axis". While this is less of an oversimplification than
viewing it as a binary choice, it is still a massive oversimplification.
A scale implies consistency of features and order amongst languages
that simply does not exist. Languages differ significantly in the
implicit and explicit conversions they allow between types, how they
handle operators on different types, and how much control they give the
programmer for how this works on their own types.
I think it is okay to have brief summaries - "Python has dynamic strong
typing, C has static weak typing". But those are vague, relative
statements that miss much of the important details.
Technical Details
Message-ID:
<11ejfdd$9hsv$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!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> <11eitqh$1t2$1@reader2.panix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: C and its peasant 'ancestors' Date: Mon, 30 Nov 2026 10:25:00 +0100 Organization: A noiseless patient Spider Lines: 74 Message-ID: <11ejfdd$9hsv$1@dont-email.me> 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> <11eitqh$1t2$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 30 Nov 2026 09:25:02 +0000 (UTC) Injection-Info: dont-email.me; logging-data="313247"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cZuC6JZaAV9Arti1n75Wwzu9A4iKFj3M="; posting-host="a448ec79be8238d2c3ca54b79fa3e2af" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:/bQnUKVn9lyFIWwVohsFiex/oWw= sha256:+SKbUQXR6c5ShVVnTcqjhIlpkN8OU1ZU+lqqqPW2024= sha1:jm02Di1d5AxyMQuKlATZMJoAHNY= sha256:1y2rLf0LkxdiSWiezmQoTt0ryA+l3swvdO31RAPEab8= In-Reply-To: <11eitqh$1t2$1@reader2.panix.com> Content-Language: en-GB, nb-NO