C++ Logo

std-proposals

Advanced search

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

From: Hyman Rosen <hyrosen_at_[hidden]>
Date: Mon, 8 Jul 2019 15:19:15 -0400
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);

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);

Received on 2019-07-08 14:21:20