On Wednesday, 10 August 2016 at 20:36:38 UTC, Dicebot wrote:
http://forum.dlang.org/post/[email protected]
The first DIP has just landed into the new queue. It is a
proposal from language authors and thus it bypasses usual
nitpicking process and proceeds straight to requesting
community (your!) feedback.
Essentially, it is an attempt to solve reference lifetime
problem by extending implementation of `scope` keyword.
Proposal text:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md
Few notes:
- Please submit pull requests to adjust the markdown document
if you want to propose any improvements (mentioning
@WalterBright and @andralex for confirmation).
- The proposal refers to a number of other documents and it is
recommended to become familiar at least briefly with all of
them.
- At this point the question I'd personally suggest to be
evaluated is "does this proposal enable enough useful
designs?". A good check would be to try taking some of your
projects and see if having DIP1000 approved and implemented
could improve them.
There is confusion between what lifetime and visibility in the
DIP.
(Well, I am confused)
1) infinite lifetime null
int * p;
The lifetime(p) is infinite while the visibility(p) starts here.
It seems to be the lifetime of p is determined by the value
assigned to it,
which in this case is null and the lifetime of lifetime(null) is
infinite.
2) Fundamentals of scope.
This declares 4 scope rules as of 11 August of which the first
rule is:
"A scope variable can only be initialized and assigned from
values that have lifetimes longer than the variable's lifetime"
int global_var;
int* global_ptr;
void bar(scope int* input);
void fun1() {
scope int* a = &global_var; // OK per rule 1,
lifetime(&global_var) > lifetime(a)
int b;
a = &b; // Disallowed per rule 1, lifetime(&b) < lifetime(a)
Shouldn't the rule be:
"A scope variable can only be initialized and assigned from
values that have lifetimes longer than the variable's VISIBILITY"
As in the case above. What is the lifetime(a) "scope int *a" when
the &global_var
has not yet been assigned to it? It doesn't have a lifetime yet,
it gets the lifetime from &global_var.
Peter