C++ Logo

std-proposals

Advanced search

Re: Initial Idea of Indirect If Statement

From: Kosher Yosher <goekhan.oezdogan_at_[hidden]>
Date: Sun, 27 Oct 2019 07:58:50 +0000
@Magnus I think the same point, i.e. just saving a few keystrokes, could be
made about ranged-for.

I like the underlying idea but like the others have said, the implicit * in
there as opposed to a more general concept sits a little uneasy. It is
programmable behaviour though which is a big plus. I'd like to see more
examples!



On Sun, 27 Oct 2019, 7:24 am Magnus Fromreide via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> On Sun, Oct 27, 2019 at 02:14:51AM +1000, Andrew Tomazos via Std-Proposals
> wrote:
> > We propose a new variant of the if statement that fuses a condition
> > declaration with an indirection in the true branch. We call it an
> > 'indirect if statement'.
> >
> > An indirect if statement of the form:
> >
> > if (DECL : EXPR) X else Y;
> >
> > is equivalent to:
> >
> > {
> > auto&& __c = EXPR;
> > if (__c) {
> > DECL = *__c;
> > X;
> > } else {
> > Y; // noteworthy: DECL is not in scope here
> > }
> > }
>
>
> Is there any use case for this beyond saving a few keystrokes?
>
> What does this enable that you couldn't do before?
>
> Why is this particular construct important enough to warrant language
> support?
>
> > So for example:
> >
> > int* get();
> > /*...*/
> > }
> >
> > The motivation should be self-evident enough from the examples for this
> > first note.
>
> I suppose that the fact that I have to ask proves that the motivation ain't
> self-evident from the examples so please spell it out.
>
> /MF
>
> > Initial thoughts appreciated.
> > -Andrew.
>
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2019-10-27 03:01:18