April 24, 2013 Re: DIP 36: Rvalue References | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mehrdad | On Tuesday, 23 April 2013 at 08:13:28 UTC, Mehrdad wrote:
> On Wednesday, 10 April 2013 at 06:11:29 UTC, Zach the Mystic wrote:
>> no value type is ever unsafe.
>
> Delegates?
Well, I don't know the formal definition of a delegate, but I believe it is a pointer to a function, plus a pointer to a data frame for the function. Since it contains a pointer, it qualifies to me as a reference type. Arrays too.
|
April 24, 2013 Re: DIP 36: Rvalue References | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tuesday, 23 April 2013 at 18:41:07 UTC, Andrei Alexandrescu wrote: >> Making 'safe' ref the default is a major breaking change. > > How do you assess the size of the breakage? I think it's fairly well-understood, probably with the same meaning that you used in your own post somewhere else: http://forum.dlang.org/thread/hlh4g2$1tn0$2@digitalmars.com#post-hlh753:24270m:241:40digitalmars.com |
April 24, 2013 Re: DIP 36: Rvalue References | ||||
---|---|---|---|---|
| ||||
Posted in reply to kenji hara | On 04/24/2013 02:41 AM, kenji hara wrote:
> ...
>
> 1. "parameterized-ref" is already there with the syntax `auto ref`.
> Removing it introduces breaking language change.
>
> 2. If we remove "parameterized-ref" from D, we will lose the ability to
> write certain kind of template functions. For example:
>
> auto ref forward(T)(auto ref T arg) { return arg; }
>
> The parameter `arg` is instantiated with both ref/non-ref, and forward
> `function` returns also both ref/non-ref value. In such case, you cannot
> replace "parameterized-ref" to "rvalue-ref".
>
> These are why DIP36 is necessary. Repeatedly, I think removing current
> `auto ref` is not good.
>...
We could specify that if there is no influence (to be made more precise) of the actual ref-ness for the function semantics, the second copy is elided. It is then illegal for non-templated functions to require multiple copies.
This would merge the two features under the name auto ref.
|
Copyright © 1999-2021 by the D Language Foundation