Date: Sat, 12 Aug 2023 18:14:28 +0200
sob., 12 sie 2023 o 17:43 Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> napisaĆ(a):
>
> On Saturday, 12 August 2023 08:33:27 PDT Thiago Macieira via Std-Proposals
> wrote:
> > So I'll help. Of what it provided, this is the only one that is a currently
> > accepted and acceptable syntax:
> >
> > int nrvo monkey;
> >
> > With nrvo being a new keyword, possibly context-sensitive like final and
> > override.
>
> You know what would help here? Not having a new keyword. So if we could reuse
> an existing keyword in a way that it can't today be used, it could convey the
> meaning we need.
>
> And there is such a keyword: return.
>
> int return monkey;
>
> This would probably require that the keyword not appear in the first position,
> so as to not be confused for a return statement.
>
What is the point of any keyword or anything else there?
why code like:
```
Mutex m;
return m;
```
could not work out of the box? We only need prepare wording
when we can use and return local objects that
are not movable. And If I recall correctly most of this
work is done for movable types.
Probably the only thing we would need is `[[nrvo]]` to
catch cases where movable type is moved out
instead of created on the return slot.
```
{
int [[nrvo]] i = 0;
if (x) return 0; //compiler error, `i` was defined `nrvo` but
// diffrent object was returned during life time of `i`
return i;
}
return 42; //ok, `i` was be created in return slot but it was already destroyed
```
Attribute is here only to state intention and prevent errors
(like the user wanted NRVO but the compiler could not provide it).
This should be general rule in lange, identity of returned object
should be always preserved (if returning thing is of course unabigius).
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
<std-proposals_at_[hidden]> napisaĆ(a):
>
> On Saturday, 12 August 2023 08:33:27 PDT Thiago Macieira via Std-Proposals
> wrote:
> > So I'll help. Of what it provided, this is the only one that is a currently
> > accepted and acceptable syntax:
> >
> > int nrvo monkey;
> >
> > With nrvo being a new keyword, possibly context-sensitive like final and
> > override.
>
> You know what would help here? Not having a new keyword. So if we could reuse
> an existing keyword in a way that it can't today be used, it could convey the
> meaning we need.
>
> And there is such a keyword: return.
>
> int return monkey;
>
> This would probably require that the keyword not appear in the first position,
> so as to not be confused for a return statement.
>
What is the point of any keyword or anything else there?
why code like:
```
Mutex m;
return m;
```
could not work out of the box? We only need prepare wording
when we can use and return local objects that
are not movable. And If I recall correctly most of this
work is done for movable types.
Probably the only thing we would need is `[[nrvo]]` to
catch cases where movable type is moved out
instead of created on the return slot.
```
{
int [[nrvo]] i = 0;
if (x) return 0; //compiler error, `i` was defined `nrvo` but
// diffrent object was returned during life time of `i`
return i;
}
return 42; //ok, `i` was be created in return slot but it was already destroyed
```
Attribute is here only to state intention and prevent errors
(like the user wanted NRVO but the compiler could not provide it).
This should be general rule in lange, identity of returned object
should be always preserved (if returning thing is of course unabigius).
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2023-08-12 16:14:41