Re: Scope and Ref and Borrowing

2014-11-18 Thread via Digitalmars-d
On Monday, 17 November 2014 at 20:07:54 UTC, Freddy wrote: Why not make the compiler copy the variable how's address is taken to the heap like how a closure does it? Would it be hard that optimize away? int* c; int main(){ int a; int* b=a;//a is now a reference to the heap

Re: Scope and Ref and Borrowing

2014-11-18 Thread Marco Leise via Digitalmars-d
I have to say I mostly settled with Marc Schütz's approach to lifetime management already, because it allows us to return scope ref arguments from functions by directly declaring which arguments the result can be referring to. So you can for example write sub-string search algorithms that can

Re: Scope and Ref and Borrowing

2014-11-17 Thread Freddy via Digitalmars-d
On Friday, 14 November 2014 at 01:21:07 UTC, Walter Bright wrote: Thought I'd bring this up as deadalnix is working on a related proposal. It uses 'scope' in conjunction with 'ref' to resolve some long standing @safe issues. --- **Background The goal of

Re: Scope and Ref and Borrowing

2014-11-14 Thread Kagamin via Digitalmars-d
On Friday, 14 November 2014 at 01:21:07 UTC, Walter Bright wrote: ref T foo() @safe { T t; ref T func() { return t; } auto dg = func; return dg(); // should be disallowed } ref T f(ref T delegate() dg) { return dg(); //ok? } On Friday, 14 November 2014 at 05:38:34 UTC,

Re: Scope and Ref and Borrowing

2014-11-14 Thread Foo via Digitalmars-d
Remembers me a bit of http://wiki.dlang.org/DIP36

Scope and Ref and Borrowing

2014-11-13 Thread Walter Bright via Digitalmars-d
Thought I'd bring this up as deadalnix is working on a related proposal. It uses 'scope' in conjunction with 'ref' to resolve some long standing @safe issues. --- **Background The goal of @safe code is that it is guaranteed to be memory safe. This is mostly

Re: Scope and Ref and Borrowing

2014-11-13 Thread Manu via Digitalmars-d
On 14 November 2014 11:20, Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: Thought I'd bring this up as deadalnix is working on a related proposal. It uses 'scope' in conjunction with 'ref' to resolve some long standing @safe issues. ---

Re: Scope and Ref and Borrowing

2014-11-13 Thread Walter Bright via Digitalmars-d
On 11/13/2014 7:41 PM, Manu via Digitalmars-d wrote: I'm not quite clear; are you suggesting 'scope ref' would be a storage class? Yes. (looks like it, but it also affects mangling?) Only for function types. Please, consider Marc Schütz's existing proposal. Please, please, don't make

Re: Scope and Ref and Borrowing

2014-11-13 Thread Walter Bright via Digitalmars-d
On 11/13/2014 9:36 PM, Walter Bright wrote: Got a handy link to it? Found it: http://wiki.dlang.org/User:Schuetzm/scope