3 ms·
Pretty much everyone agrees that the "best" syntax for declarations is Go-style "x: int;" and not C-style "int x;", but to be fair you don't see declarations li
by qsort 6y ago
Pretty much everyone agrees that the "best" syntax for declarations is Go-style "x: int;" and not C-style "int x;", but to be fair you don't see declarations like that very often. Once you understand the (admittedly bad) syntax for "pointer to function returning type" as opposed to "function returning pointer to type", most declarations you're likely to find aren't hard to read.
I mantain some C code as part of my job and I don't recall declarations ever being a problem to mentally parse.
- coldpie 6y agoThe only truly difficult declarations I've encountered dealing with real-world C code is mixing pointers, const, and arrays. Pointer to const str, easy: const char *str; array of pointers to const strs, also fairly easy: const char *strs[4]; const array of pointers to const strs... umm... const char *const strs[4]; I think? Which const does what? This is a dummy example, but real-world examples can be a bit less obvious, as you sometimes have to elide the array length: const char* const* enabledExtensionNames; From: https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrinstancecreateinfo3 https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/o... What is this, again?