C++ Logo

std-proposals

Advanced search

Re: Making parameter names clearer than func(true, false);

From: Jonny Grant <jg_at_[hidden]>
Date: Mon, 8 Jul 2019 20:29:06 +0100
On 08/07/2019 20:23, Ville Voutilainen via Std-Proposals wrote:
> On Mon, 8 Jul 2019 at 22:19, Hyman Rosen via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>>
>> On Mon, Jul 8, 2019 at 2:41 PM Thiago Macieira <thiago_at_[hidden]> wrote:
>>>
>>> So when coming up with examples of where named parameters would be useful,
>>> please find good APIs that would become even better, or at least find bad ones
>>> that have other reasons for being bad.
>>
>>
>> Posix system calls, an API that isn't about to change and doesn't care whether you
>> think it's good or bad:
>> ssize_t int write(int fd, void *buf, size_t count);
>
> If the API isn't about to change, you're unlikely to be able to call
> it with named arguments.

What might be difficult is that different libc in this case have
different parameter names. Unfortunately what I desire (named
parameters) might not work on code that needs to compile on both BSD and
GNU/Linux. (I would end up needing to write inline wrappers (yuk!)


BSD
ssize_t write(int fd, const void *buf, size_t nbytes);


Glibc
ssize_t write(int fd, const void *buf, size_t count);


I'm not sure why MSDN deprecated POSIX write() but anyway, they have
_write as :
int _write(
    int fd,
    const void *buffer,
    unsigned int count
);

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/write?view=vs-2019

Received on 2019-07-08 14:31:02