Comparison to Go?
Comparison to Go?
Posted Jan 6, 2025 19:05 UTC (Mon) by rweikusat2 (subscriber, #117920)In reply to: Comparison to Go? by dvdeug
Parent article: Preventing data races with Pony
> The fact that the C standard calls char an integer type is why C doesn't care. It doesn't change the fact you're
> adding a character to a pointer, it just means that C doesn't see it that way.
There is no such thing as a character type in C and hence, there's no way to add a character to anything in C. That's a fact which is part of the language definition.
> If someone is arguing that C's type system is deficient because it lets you add a bool to a float, it doesn't help to
> point out that C just treats bools as integers.
Likewise, there is no such things as a bool type in C that's distinct from an integer type and hence, adding a bool to a float is also something that's impossible in C. That's also part of the C language definition. It's obviously possible to argue that the C type system should really contain concepts like character or boolean types but as a matter of fact, it doesn't. Hence, this particular criticism is disingenuous. C allows addition of numbers and due to the relative paucity of the type system, numbers are also employed to represent entities (like characters or boolean values) which have types of their own in other programming languages. But that's strictly a matter of interpretation. 97 is an integer. In certain contexts, it might represent the character a and in others, it doesn't.
Posted Jan 6, 2025 19:34 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link] (1 responses)
What is a "character type"?
Posted Jan 6, 2025 19:46 UTC (Mon)
by adobriyan (subscriber, #30858)
[Link]
"char" of course officially exists now: _Generic dispatches on "char" as it does on "_Bool".
Posted Jan 7, 2025 4:41 UTC (Tue)
by dvdeug (guest, #10998)
[Link]
> There is no such thing as a character type in C and hence, there's no way to add a character to anything in C.
No, this particular criticism is not disingenuous. What's disingenuous is when you take a language that has built-in features to handle character data and a type designed to hold character data (named char) and character constants, where you can take a pointer p and add 'a' to it, and act like criticizing that is unreasonable because the text of the standard doesn't have a character type.
Oh, and C11 ยง6.2.5.15 says "The three types char, signed char, and unsigned char are collectively called the character types." I don't have access to all the C standards documents, but at least that one officially says it has character types. So not only is your claim trying to use pedantry to avoid reality, it's using pedantry that's not correct.
Comparison to Go?
Comparison to Go?
Informally, BTCP recognised "char" as real type for quite some time.
Comparison to Go?
...
> It's obviously possible to argue that the C type system should really contain concepts like character or boolean types but as a matter of fact, it doesn't. Hence, this particular criticism is disingenuous.