radical ideas about GC and ARC : need to be time driven?

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Tue May 13 00:16:35 PDT 2014


Am Mon, 12 May 2014 08:44:51 +0000
schrieb "Marc Schütz" <schuetzm at gmx.net>:

> On Monday, 12 May 2014 at 04:22:21 UTC, Marco Leise wrote:
> > On the positive side the talk about Rust, in particular how
> > reference counted pointers decay to borrowed pointers made me
> > think the same could be done for our "scope" args. A reference
> > counted slice with 3 machine words could decay to a 2 machine
> > word "scoped" slice. Most of my code at least just works on the
> > slices and doesn't keep a reference to them. A counter example
> > is when you have something like an XML parser - a use case
> > that D traditionally (see Tango) excelled in. The GC
> > environment and slices make it possible to replace string
> > copies with cheap slices into the original XML string.
> 
> Rust also has a solution for this: They have lifetime 
> annotations. D's scope could be extended to support something 
> similar:
> 
>      scope(input) string getSlice(scope string input);
> 
> or with methods:
> 
>      struct Xml {
>          scope(this) string getSlice();
>      }
> 
> scope(symbol) means, "this value references/aliases (parts of) 
> the value referred to by <symbol>". The compiler can then make 
> sure it is never assigned to variables with longer lifetimes than 
> <symbol>.

Crazy shit, now we are getting into concepts that I have no
idea of how well they play in real code. There are no globals,
but threads all create their own call stacks with independent
lifetimes. So at that point lifetime annotations become
interesting.

-- 
Marco



More information about the Digitalmars-d mailing list