[dmd-beta] rvalue references

Jacob Carlborg doob at me.com
Wed Apr 11 02:30:13 PDT 2012



On Apr 11, 2012, at 02:57 AM, Walter Bright <walter at digitalmars.com> wrote:

> Our D solution, disallowing rvalue references, is technically sound but as we've
> discussed here is a usability disaster, and auto ref isn't going to cut it. We
> figured a solution is:
>
> *** Allow rvalue references, however, disallow any implicit conversions of the
> literal's type in the process of taking a reference to it. ***
>
> That takes care of 1 and 2. The solution to 3 is a bit more subtle. Some people
> have wondered why the D compiler can create reference types itself, but does not
> allow the user to outside of function parameters and foreach variables. This is
> the reason why. References, in order to be safe, must not be allowed to escape a
> scope. They can only be passed downward to enclosed scopes, and returned from
> functions where the return value is checked. Also, one cannot take the address
> of a reference. I think this closes the holes.
>
> With all that, I intend to once again allow struct literals to be lvalues for
> 2.059. Somewhat later, also allow references to other literals like 0 and 5.6.

I think this should be posted on the newsgroup as well.

--
/Jacob Carlborg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120411/e79d95a4/attachment.html>


More information about the dmd-beta mailing list