|
|
|
|
|
by Luyt
6025 days ago
|
|
When I was reading this, I thought "Nooo! Don't make the size of an array part of its type!" That has been rightfully shown as a very bad idea by Brian Kernighan, see http://www.lysator.liu.se/c/bwk-on-pascal.html
Luckily the proposal is about passing a 'fat pointer', really a pointer and a length. I did that often in my C programs too: int process(char *buf, int buflen); Maybe this fix to C's Biggest Mistake, a.k.a. the 'fat pointer', is just syntactic sugar. |
|
He suggested using "fat pointers" -- pointers along with their extent. This is similar to how many Pascal compilers treat the type "String".
Kernighan mentions Pascal strings in his article but claims the solution does not scale to other types. Walter's solution does work for all array types (but admittedly has other problems).