Re: Lifetime tracking

2016-06-06 Thread Marc Schütz via Digitalmars-d
On Thursday, 2 June 2016 at 23:29:57 UTC, Timon Gehr wrote: void foo(scope int* k){ void bar(){ scope int* x; // need to check that lifetime of x ends not after lifetime of k assign(x,k); } } I.e. now we need a way to annotate 'assign' in order to specify the

Re: Lifetime tracking

2016-06-04 Thread Manu via Digitalmars-d
On 4 June 2016 at 19:14, Walter Bright via Digitalmars-d wrote: > On 6/3/2016 4:38 AM, Timon Gehr wrote: >> >> I'm sure there is some syntax that >> will feel natural to D programmers. > > > Aye, there's the rub. Nobody has found one in over 10 years, despite a lot > of discussion. What is unnatu

Re: Lifetime tracking

2016-06-04 Thread Manu via Digitalmars-d
On 3 June 2016 at 10:40, Stefan Koch via Digitalmars-d wrote: > On Friday, 3 June 2016 at 00:31:31 UTC, Walter Bright wrote: > >> If they cover the cases that matter, it's good. Rust has the type system >> annotations you want, but Rust has a reputation for being difficult to write >> code for. >

Re: Lifetime tracking

2016-06-04 Thread Walter Bright via Digitalmars-d
On 6/4/2016 2:14 AM, Walter Bright wrote: On 6/3/2016 4:38 AM, Timon Gehr wrote: I'm sure there is some syntax that will feel natural to D programmers. Aye, there's the rub. Nobody has found one in over 10 years, despite a lot of discussion. No one found one for Rust, either.

Re: Lifetime tracking

2016-06-04 Thread Walter Bright via Digitalmars-d
On 6/3/2016 4:38 AM, Timon Gehr wrote: I'm sure there is some syntax that will feel natural to D programmers. Aye, there's the rub. Nobody has found one in over 10 years, despite a lot of discussion.

Re: Lifetime tracking

2016-06-03 Thread Timon Gehr via Digitalmars-d
On 03.06.2016 02:31, Walter Bright wrote: On 6/2/2016 4:29 PM, Timon Gehr wrote: // need to know that lifetime of a ends not after lifetime of b void assign(S,T)(ref S a, T b){ a = b; } void foo(scope int* k){ void bar(){ scope int* x; // need to check that lifetime of x end

Re: Lifetime tracking

2016-06-02 Thread docandrew via Digitalmars-d
On Friday, 3 June 2016 at 00:40:09 UTC, Stefan Koch wrote: On Friday, 3 June 2016 at 00:31:31 UTC, Walter Bright wrote: If they cover the cases that matter, it's good. Rust has the type system annotations you want, but Rust has a reputation for being difficult to write code for. I think we c

Re: Lifetime tracking

2016-06-02 Thread Stefan Koch via Digitalmars-d
On Friday, 3 June 2016 at 00:31:31 UTC, Walter Bright wrote: If they cover the cases that matter, it's good. Rust has the type system annotations you want, but Rust has a reputation for being difficult to write code for. I think we can incorporate typesafe borrowing without making it difficu

Re: Lifetime tracking

2016-06-02 Thread Walter Bright via Digitalmars-d
On 6/2/2016 5:21 PM, Walter Bright wrote: Please give an example. I see you did, so ignore that.

Re: Lifetime tracking

2016-06-02 Thread Walter Bright via Digitalmars-d
On 6/2/2016 4:29 PM, Timon Gehr wrote: // need to know that lifetime of a ends not after lifetime of b void assign(S,T)(ref S a, T b){ a = b; } void foo(scope int* k){ void bar(){ scope int* x; // need to check that lifetime of x ends not after lifetime of k assign(x,

Re: Lifetime tracking

2016-06-02 Thread Walter Bright via Digitalmars-d
On 6/2/2016 4:05 PM, Timon Gehr wrote: I'd like to point out again why that design is inadequate: Whenever the type checker is using a certain piece of information to check validity of a program, there should be a way to pass that kind of information across function boundaries. Otherwise the typ

Re: Lifetime tracking

2016-06-02 Thread tsbockman via Digitalmars-d
On Thursday, 2 June 2016 at 23:29:57 UTC, Timon Gehr wrote: On 03.06.2016 01:12, tsbockman wrote: On Thursday, 2 June 2016 at 23:05:40 UTC, Timon Gehr wrote: Whenever the type checker is using a certain piece of information to check validity of a program, there should be a way to pass that kin

Re: Lifetime tracking

2016-06-02 Thread Timon Gehr via Digitalmars-d
On 03.06.2016 01:29, Timon Gehr wrote: [1] It might be possible to get that example to pass the type checker with 'return' annotations only if I change 'ref' to 'out', but often more than two lifetimes are involved, and then it falls flat on its face. To be slightly more explicit: void multi

Re: Lifetime tracking

2016-06-02 Thread Timon Gehr via Digitalmars-d
On 03.06.2016 01:12, tsbockman wrote: On Thursday, 2 June 2016 at 23:05:40 UTC, Timon Gehr wrote: Whenever the type checker is using a certain piece of information to check validity of a program, there should be a way to pass that kind of information across function boundaries. Otherwise the typ

Re: Lifetime tracking

2016-06-02 Thread tsbockman via Digitalmars-d
On Thursday, 2 June 2016 at 23:05:40 UTC, Timon Gehr wrote: Whenever the type checker is using a certain piece of information to check validity of a program, there should be a way to pass that kind of information across function boundaries. Otherwise the type system is not modular. This is a s

Re: Lifetime tracking

2016-06-02 Thread Stefan Koch via Digitalmars-d
On Thursday, 2 June 2016 at 23:05:40 UTC, Timon Gehr wrote: On 03.06.2016 00:29, Walter Bright wrote: On 6/2/2016 3:10 PM, Marco Leise wrote: we haven't looked into borrowing/scoped enough That's my fault. As for scoped, the idea is to make scope work analogously to DIP25's 'return ref'. I

Lifetime tracking

2016-06-02 Thread Timon Gehr via Digitalmars-d
On 03.06.2016 00:29, Walter Bright wrote: On 6/2/2016 3:10 PM, Marco Leise wrote: we haven't looked into borrowing/scoped enough That's my fault. As for scoped, the idea is to make scope work analogously to DIP25's 'return ref'. I don't believe we need borrowing, we've worked out another solu