Date: Mon, 8 Jul 2019 20:32:37 +0100
On 08/07/2019 20:26, Tae Lim Kook via Std-Proposals wrote:
> On Monday, July 8, 2019 3:19 PM, Hyman Rosen via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>> 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);
>>
>> Is the code
>> ssize_t written = write(2, "a", 1);
>> writing 1 byte to file descriptor 2, or 2 bytes to file descriptor 1?
>>
>> We should be able to say
>> ssize_t written = write(buf => "a", count => 1, fd => 2);
>
> I don't think this is a good example -- if we enable named
> parameters by default, then parameter names would become part
> of every API, while if we make them opt-in, then POSIX
> wouldn't be able to take advantage of them anyway without
> changing its API. Besides, Thiago asked for good APIs, not
> APIs that are unlikely to change (and I'd add APIs that are
> bad but couldn't be comparably improved by existing C++
> features).
You're right, as soon as they a required, they become part of of the
signature, and my BSD write(fd:myfd, buf:mybuf, nbytes:10); will not
compile on GNU/Linux.
For compatibility I'd end up leaving the parameter names out of code
that calls libraries with different parameter names for the same POSIX
functions :(
> On Monday, July 8, 2019 3:19 PM, Hyman Rosen via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
>> 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);
>>
>> Is the code
>> ssize_t written = write(2, "a", 1);
>> writing 1 byte to file descriptor 2, or 2 bytes to file descriptor 1?
>>
>> We should be able to say
>> ssize_t written = write(buf => "a", count => 1, fd => 2);
>
> I don't think this is a good example -- if we enable named
> parameters by default, then parameter names would become part
> of every API, while if we make them opt-in, then POSIX
> wouldn't be able to take advantage of them anyway without
> changing its API. Besides, Thiago asked for good APIs, not
> APIs that are unlikely to change (and I'd add APIs that are
> bad but couldn't be comparably improved by existing C++
> features).
You're right, as soon as they a required, they become part of of the
signature, and my BSD write(fd:myfd, buf:mybuf, nbytes:10); will not
compile on GNU/Linux.
For compatibility I'd end up leaving the parameter names out of code
that calls libraries with different parameter names for the same POSIX
functions :(
Received on 2019-07-08 14:34:33