C++ Logo

std-proposals

Advanced search

Re: Initialisers in ternary operators

From: Richard Hodges <hodges.r_at_[hidden]>
Date: Tue, 15 Sep 2020 21:46:47 +0200
On Tue, 15 Sep 2020 at 21:38, Jorg Brown via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Mon, Sep 14, 2020 at 6:18 AM Dmitry Dmitry via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> The first question that springs to mind is "where do I place the
>>> breakpoint so I can see the current state of this algorithm?"
>>>
>>
>> This was my first question as well :)
>>
>
> So I'm looking at http://wg21.link/p0798 ...
>
> I get that you don't like (nor do I):
>
> std::optional<image> get_cute_cat (const image& img) {
> return crop_to_cat(img)
> .and_then(add_bow_tie)
> .and_then(make_eyes_sparkle)
> .transform(make_smaller)
> .transform(add_rainbow);
> }
>
> I'm curious if you would allow the pre-P0798 version:
>
> image get_cute_cat (const image& img) {
> return add_rainbow(
> make_smaller(
> make_eyes_sparkle(
> add_bow_tie(
> crop_to_cat(img))));
> }
>

My objections would not be as strong because the flow can actually be
followed and there is no irrelevant glue code obfuscating intent.

It would also be easier to temporarily refactor the code so that it
assigned to intermediate variables to aid debugging and/or coverage.

>
>
> -- Jorg
>
>
> --
>
> Std-Proposals mailing list
>
> Std-Proposals_at_[hidden]
>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
Richard Hodges
hodges.r_at_[hidden]
office: +442032898513
home: +376841522
mobile: +376380212

Received on 2020-09-15 14:47:00