Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I like C but not its syntax

Name: Anonymous 2014-12-02 12:11

Why hasn't anyone made C that doesn't look like dogshit?

Name: Anonymous 2014-12-03 16:12

>>23-25,31
You do not understand C. Naturally you are frustrated and confused by what you do not understand. But, as I know better, I will selflessly go out of my way to enlighten you.

In other languages, you would write the identifier, and then the identifier's type: Foo : Integer, Bar : Map<String, Float>, and word []char. But the syntax for declaring such identifiers is completely different from the syntax for using them in your code, which complicates the language: You must be able to express both the name of the type itself and the way it is used.

In C, there is a different basic rule: You write the type of an expression (the contents of a dereferenced pointer or array, or the return value of a function) and then you write an expression invoking the identifier you are declaring, using exactly the same syntax as you would in normal code. And naturally, the type of that expression is the same type that precedes it in the declaration: The type of *p is int, and therefore you would write int *p. The type of buf[n] is unsigned char, and therefore you would write unsigned char buf[BUFSIZ].

If it were not done this way, C would need additional syntax for each of these types: A special syntax for function types, a special syntax for pointer types, and so on. Reusing what is already there allows the compiler to save precious memory and grammar complexity by simplifying the language. It is the best choice a language designer could have made.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List