Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2020-09-10 15:47:44


Am 10.09.20 um 17:44 schrieb Vinnie Falco:
> On Thu, Sep 10, 2020 at 8:15 AM Alexander Grund via Boost
> <boost_at_[hidden]> wrote:
>>> s.read( buf ) writes data to the buffer you supply
>> I get the rationale. But reading that code I would expect that "s" reads
>> from "buf". So to me the behavior is confusing and hence error prone.
>> Could you explore alternatives?
> I agree that there is some confusion, but I believe that confusion is
> unavoidable. In other words no matter what the verb, it will always be
> subject to interpretation both ways. The way I "break the tie" is
> simply to follow the convention used in networking. You read from a
> socket into your mutable buffer. You write to a socket from your const
> buffer. We could explore alternatives, but then there would be a lack
> of consistency. While I am usually not one to prioritize consistency
> over every other consideration, in this particular case it does make
> sense.
How about: `s.read_into(buf)`? That almost reads like English and makes
it clear(er). This can also be misinterpreted but may be slightly better




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk