Deterministic life-time storage type

Michel Fortin michel.fortin at michelf.com
Sat Apr 21 19:16:40 PDT 2012


On 2012-04-21 14:22:41 +0000, travert at phare.normalesup.org (Christophe) said:

> This scope system is very similar to the mutable/immutable system. It is
> optionnal (one may code without it). There is transitivity, a bridge
> type (const or scope(in)), and also the same virality (is this an
> english word??). This means that to be usable, this system requires to
> restrict the usage of parameters and returned value of the functions by
> appropriate keywords (scope(in, out or inout), otherwise a scoped
> variable can't be passed to a function and is not usable in practice.
> But in my opinion, the gain is very large. When used, variable lifetimes
> becomes deterministic, the compiler can destroy them at the right time,
> and use the GC only when necessary, or with global variables.

I fear your solution might not be complicated enough (!) to allow some 
common patterns. One simple case that often challenges such proposals 
is the swap function.

So with your system, how do you write the swap function?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list