[dmd-beta] D 2.059 beta 4
Walter Bright
walter at digitalmars.com
Tue Apr 10 09:25:57 PDT 2012
On 4/10/2012 3:59 AM, Steve Schveighoffer wrote:
> If I understand correctly (and I very well might not), the idea is that auto
> ref is *always* ref, so only one function is generated.
No. Two functions are generated.
> The main difference between auto ref and ref is that ref doesn't allow
> rvalues. Saying auto ref is basically like saying to the compiler: "yeah, I
> know it's an rvalue, still pass it as ref".
>
> If that's correct, I think the way to look at it is these three situations:
>
> 1. I want to change the value, and/or I want to disallow rvalues: use ref
> 2. I want to pass by reference because the struct is large: use auto ref
> (includes rvalues), possibly const as well.
> 3. I want to optimize passing large structs for both rvalues and lvalues: use
> two overloads, one with const ref, one by value.
>
> Andrei, I hate to ask this, because I feel very confused from all the
> statements you have previously made, but could you explain this again?
>
> To be honest, if what I've said is correct, it still sounds so clunky and
> awkward...
>
> -Steve
>
> --------------------------------------------------------------------------------
> *From:* Walter Bright <walter at digitalmars.com>
> *To:* Discuss the dmd beta releases for D <dmd-beta at puremagic.com>
> *Sent:* Monday, April 9, 2012 11:55 PM
> *Subject:* Re: [dmd-beta] D 2.059 beta 4
>
>
>
> On 4/9/2012 7:44 PM, Jonathan M Davis wrote:
> > On Monday, April 09, 2012 19:40:43 Walter Bright wrote:
> >> On 4/9/2012 7:32 PM, Nick Sabalausky wrote:
> >>> Although, if there really is good merit to struct lits not veing lvalues,
> >>> then maybe all we need is to wait until "auto ref" is usable for
> >>> non-templates? (If that would even be possible...?)
> >> Not possible, as the binary ABI would be different.
> > It was my understanding that the auto ref was supposed to work with non-
> > templated functions - at least what Andrei proposed was - but that you
> > misunderstood that and made it only work with templates. And as long as it
> > only works with templates, it's usefulness is very limited. opEquals
> would be
> > a _prime_ case for where it would be useful.
> >
>
> How could that possibly work for the same function, considering that the code
> for each would be quite different, including the calling code?
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com <mailto:dmd-beta at puremagic.com>
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
>
>
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120410/077205c5/attachment.html>
More information about the dmd-beta
mailing list