Opportunities for D

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 9 22:41:33 PDT 2014


On Thu, Jul 10, 2014 at 05:12:23AM +0200, Timon Gehr via Digitalmars-d wrote:
[...]
> - Lifetime parameters. (it's more future-proof if they are not
> introduced by simple identifiers.)
> 
> Eg.: void foo[lifetime lt](int x){ ... }
> 
> 
> - Attaching a lifetime to a pointer, class reference, ref argument.
> 
> Eg.: void foo[lifetime lt](int scope(lt)* x){ ...}
>      void foo[lifetime lt](scope(lt) C c){ ... }
>      void foo[lifetime lt](scope(lt) ref int x){ ... }
>      void foo[lifetime lt1,lifetime lt2](scope(lt1)(C)scope(lt2)[] a){ ... }
> 
> (The last example talks about a slice where the array memory has
> different lifetimes than the class instances it contains.)
[...]

This is starting to look like some parts of my 'scope' proposal in
another part of this thread.

I'm wondering if it makes sense to simplify lifetimes by tying them to
lexical context rather than using explicit annotations? Being able to
specify explicit lifetimes seem a bit excessive to me, but perhaps you
have a use case in mind that I'm not aware of?


T

-- 
People demand freedom of speech to make up for the freedom of thought which they avoid. -- Soren Aabye Kierkegaard (1813-1855)


More information about the Digitalmars-d mailing list