On 30/11/2026 05:24, Dan Cross wrote:
> In article <11ei…@kst.eternal-september.org>,
> Keith Thompson <Keit…@gmail.com> wrote:
>> cro…@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.