3 ms·
> Likewise, size_t tells you that this is a size, no need for the "n". How do you differentiate the two input lengths? If I were to rename `xp` to `x` and `xn`
by chjj 5y ago
> Likewise, size_t tells you that this is a size, no need for the "n".
How do you differentiate the two input lengths? If I were to rename `xp` to `x` and `xn` to `n`, what should `yn` be renamed to? At the very least, there's going to need to be a `yn` somewhere.
It's very common for code to include the type when there are two inputs to a function (even when written more verbosely): e.g. `thing_len`, and `other_thing_len`.
The `p`-suffix convention can also save you in a situation like this:
int x = 1;
int *xp = &x;
int y = 1;
int *yp = &y;
It avoids naming collisions, and further down in the function, you'll be able to differentiate the pointer and the value. I find it very useful.
If you write multi-precision integer code in C[1] without this convention, you will end up with an unreadable mess. I certainly wish Torbjörn Granlund were here to testify to this.
[1] https://github.com/chjj/mako/blob/master/src/mpi.c https://github.com/chjj/mako/blob/master/src/mpi.c