Proposal for design of 'scope' (Was: Re: Opportunities for D)
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 15 00:19:34 PDT 2014
On 15/07/14 01:48, H. S. Teoh via Digitalmars-d wrote:
> Yes, but since the extent of this scope is unknown from inside the
> function body, it doesn't easily lend itself nicely to check things like
> this:
>
> int* ptr;
> void func(scope int* arg) {
> ptr = arg; // should this be allowed?
> }
>
> If we only know that 'arg' has a longer lifetime than func, but we don't
> know how long it is, then we don't know if it has the same lifetime as
> 'ptr', or less. So it doesn't really let us do useful checks.
I was thinking that "arg" would have at least the same lifetime as the
caller, i.e. the same as "ptr".
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list