DIP1000: Scoped Pointers (Discussion)

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 15 05:17:29 PDT 2016


On 08/15/2016 02:52 PM, Walter Bright wrote:
> On 8/15/2016 2:32 AM, Kagamin wrote:
>> On Sunday, 14 August 2016 at 20:02:35 UTC, Walter Bright wrote:
>>> auto r = range;
>>
>> You said that if a value (range in this case) is returned by scope,
>> its lifetime
>> is restricted to its expression, hence it can't be assigned to a
>> variable,
>> because the variable outlives the expression.
> 
> A very good question. If the functions parameters are 'return scope',
> that means the returned value has the (smallest) scope if its 'return
> scope' parameters. If there are no 'return scope' parameters, the scope
> of the return value is limited to the expression.

Does that mean that a scope return in aggregate method will bind to
aggregate lifetime if method itself is annotated with scope too? For
example:

struct Container
{
    scope Range asRange ( ) scope
    {
        return Range(&this.data);
    }
}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20160815/4b96b462/attachment.sig>


More information about the Digitalmars-d mailing list