News for hackers. Stuff that matters.
Re:Const all the things? by lelanthran on Monday January 24, 2022 @06:14AM (#30056124)
> I don't remember the last time where I passed an argument to a C++ function and actually had to wonder if the argument was modified or not. Like, what if they are being modified if that's the called function has to do anyways

That's not what I was complaining about. I am saying that, as a reader of the code, it is easier to reason about what happens in this situation:

    foo (&bar);
    ...
    if (bar) { do something }
than in this situation:

    foo (bar);
    ...
    if (bar) { do something }


> mynet_accept({ .fd = the_socket, .port = 4556 });

That's not functionally the same as the example I posted. In any case, I was using the example to point out that using pointers provides a more flexible API contract.

When using pointers, the contract can state that any parameters that are NULL are ignored, whether they are out parameters or not.

There are no comments on this comment yet.