Re: The next iteration of scope

2015-04-04 Thread Walter Bright via Digitalmars-d
On 4/2/2015 4:44 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: But I hope overloading is included under point 1. It's very important for efficiency. I'm not convinced of the need for overloading on 'scope'.

Re: The next iteration of scope

2015-04-04 Thread bearophile via Digitalmars-d
Walter Bright: I'm not convinced of the need for overloading on 'scope'. Do you want to explain some of the advantages and disadvantages of that? It will help understand your reasons. Bye, bearophile

Re: The next iteration of scope

2015-04-02 Thread ketmar via Digitalmars-d
On Thu, 02 Apr 2015 08:45:10 +0200, Jacob Carlborg wrote: Why should the non-template functions that _have_ the source code available suffer? 'cause inferring attributes requires running full semantic analysis on the code, so each imported function *must* be fully processed. and with

Re: The next iteration of scope

2015-04-02 Thread Andrei Alexandrescu via Digitalmars-d
On 4/1/15 11:45 PM, Jacob Carlborg wrote: On 2015-04-01 22:26, Walter Bright wrote: The problem with inferring attributes on non-template functions is the source must be available to the compiler. That's obviously true for templates, but not so true for non-templates, where only the signature

Re: The next iteration of scope

2015-04-02 Thread Jacob Carlborg via Digitalmars-d
On 2015-04-01 22:26, Walter Bright wrote: The problem with inferring attributes on non-template functions is the source must be available to the compiler. That's obviously true for templates, but not so true for non-templates, where only the signature is available. In my experience with D,

Re: The next iteration of scope

2015-04-02 Thread ketmar via Digitalmars-d
On Thu, 02 Apr 2015 06:59:40 +, ketmar wrote: On Thu, 02 Apr 2015 08:45:10 +0200, Jacob Carlborg wrote: Why should the non-template functions that _have_ the source code available suffer? 'cause inferring attributes requires running full semantic analysis on the code, so each

Re: The next iteration of scope

2015-04-02 Thread via Digitalmars-d
On Wednesday, 1 April 2015 at 23:03:02 UTC, bearophile wrote: Walter Bright: I'm thinking of a modest step which would be a subset of your proposal: 1. implement 'scope' and 'return' for arrays, classes, and pointers 2. implement inference for templates and lambdas 3. enable it with the

Re: The next iteration of scope

2015-04-02 Thread Jacob Carlborg via Digitalmars-d
On 2015-04-02 08:59, ketmar wrote: 'cause inferring attributes requires running full semantic analysis on the code, so each imported function *must* be fully processed. Isn't this required anyway? -- /Jacob Carlborg

Re: The next iteration of scope

2015-04-02 Thread ketmar via Digitalmars-d
On Thu, 02 Apr 2015 13:39:01 +0200, Jacob Carlborg wrote: On 2015-04-02 08:59, ketmar wrote: 'cause inferring attributes requires running full semantic analysis on the code, so each imported function *must* be fully processed. Isn't this required anyway? .di files has no function bodies,

Re: The next iteration of scope

2015-04-02 Thread ketmar via Digitalmars-d
On Thu, 02 Apr 2015 16:04:59 +0200, Jacob Carlborg wrote: On 2015-04-02 14:02, ketmar wrote: .di files has no function bodies, yet they still works. so compiler *can* do full processing, but it is not required, and if compiler does that, this restriction can be removed in the future. but

Re: The next iteration of scope

2015-04-02 Thread Jacob Carlborg via Digitalmars-d
On 2015-04-02 14:02, ketmar wrote: .di files has no function bodies, yet they still works. so compiler *can* do full processing, but it is not required, and if compiler does that, this restriction can be removed in the future. but with automatic inference for functions we are stuck with full

Re: The next iteration of scope

2015-04-01 Thread via Digitalmars-d
On Tuesday, 31 March 2015 at 20:07:19 UTC, Walter Bright wrote: Consider the code: struct Foo { C obj; } @safe void bar(C c, Foo* f) { f.obj = c; } Under the proposal, for @safe code, this would have to be written as: @safe void bar(static C c, Foo* f) ... Either that, or:

Re: The next iteration of scope

2015-04-01 Thread Walter Bright via Digitalmars-d
On 4/1/2015 10:00 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Tuesday, 31 March 2015 at 20:07:19 UTC, Walter Bright wrote: Consider the code: struct Foo { C obj; } @safe void bar(C c, Foo* f) { f.obj = c; } Under the proposal, for @safe code, this would have to be written

Re: The next iteration of scope

2015-04-01 Thread bearophile via Digitalmars-d
Walter Bright: I'm thinking of a modest step which would be a subset of your proposal: 1. implement 'scope' and 'return' for arrays, classes, and pointers 2. implement inference for templates and lambdas 3. enable it with the -dip25 switch and see how far that takes us. This is

Re: The next iteration of scope

2015-03-31 Thread Walter Bright via Digitalmars-d
On 3/15/2015 7:10 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the implementation, and a more formal specification, as well as a discussion of

Re: The next iteration of scope

2015-03-22 Thread via Digitalmars-d
On Sunday, 15 March 2015 at 14:10:02 UTC, Marc Schütz wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the implementation, and a more formal specification, as well as a discussion of backwards

Re: The next iteration of scope

2015-03-22 Thread Andrei Alexandrescu via Digitalmars-d
On 3/22/15 12:29 PM, Andrei Alexandrescu wrote: Then I also need to get diverted into PR work like improving byLine. Here PR stands for Public Relations. -- Andrei

Re: The next iteration of scope

2015-03-22 Thread Andrei Alexandrescu via Digitalmars-d
On 3/22/15 10:20 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Sunday, 15 March 2015 at 14:10:02 UTC, Marc Schütz wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the

Re: The next iteration of scope

2015-03-19 Thread deadalnix via Digitalmars-d
On Wednesday, 18 March 2015 at 13:01:50 UTC, Oren Tirosh wrote: The scope storage class is a two way contract. The function promises not to escape the reference. The caller promises to ensure the storage that the reference is pointing to will remain valid for the duration of the function call.

Re: The next iteration of scope

2015-03-18 Thread Oren Tirosh via Digitalmars-d
On Sunday, 15 March 2015 at 19:11:36 UTC, Marc Schütz wrote: On Sunday, 15 March 2015 at 17:31:17 UTC, Nick Treleaven wrote: On 15/03/2015 14:10, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's

Re: The next iteration of scope

2015-03-18 Thread Zach the Mystic via Digitalmars-d
On Wednesday, 18 March 2015 at 13:01:50 UTC, Oren Tirosh wrote: On Sunday, 15 March 2015 at 19:11:36 UTC, Marc Schütz wrote: On Sunday, 15 March 2015 at 17:31:17 UTC, Nick Treleaven wrote: On 15/03/2015 14:10, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Here's the new version of my

Re: The next iteration of scope

2015-03-17 Thread via Digitalmars-d
On Tuesday, 17 March 2015 at 01:13:41 UTC, Zach the Mystic wrote: On Monday, 16 March 2015 at 20:50:46 UTC, Marc Schütz wrote: It works just the same: struct S { private int* payload_; ref int* payload() return { return payload_; } } ref int* payload(scope ref S __this) return

Re: The next iteration of scope

2015-03-16 Thread Zach the Mystic via Digitalmars-d
On Monday, 16 March 2015 at 20:50:46 UTC, Marc Schütz wrote: On Monday, 16 March 2015 at 19:43:01 UTC, Zach the Mystic wrote: I always tend to think of member functions as if they weren't: struct S { T t; ref T fun() return { return t; } } In my head, I just translate fun() above to:

Re: The next iteration of scope

2015-03-16 Thread via Digitalmars-d
On Monday, 16 March 2015 at 04:00:51 UTC, Zach the Mystic wrote: Functions and methods can be overloaded on scope. This allows efficient passing of RC wrappers for instance... How does the compiler figure out which of the variables it's passing to the parameters are `scope` or not? Does the

Re: The next iteration of scope

2015-03-16 Thread via Digitalmars-d
On Monday, 16 March 2015 at 12:21:17 UTC, Nick Treleaven wrote: On 15/03/2015 19:11, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Sunday, 15 March 2015 at 17:31:17 UTC, Nick Treleaven wrote: I too want a scope attribute e.g. for safe slicing of static arrays, etc. I'm not sure if

Re: The next iteration of scope

2015-03-16 Thread bearophile via Digitalmars-d
Marc Schütz: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 Let's see what Andrei and Walter think about this all :-) Bye, bearophile

Re: The next iteration of scope

2015-03-16 Thread Nick Treleaven via Digitalmars-d
On 15/03/2015 19:11, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Sunday, 15 March 2015 at 17:31:17 UTC, Nick Treleaven wrote: I too want a scope attribute e.g. for safe slicing of static arrays, etc. I'm not sure if it's too late for scope by default though, perhaps. If we get

Re: The next iteration of scope

2015-03-16 Thread Nick Treleaven via Digitalmars-d
On 16/03/2015 04:00, Zach the Mystic wrote: struct RC(T) if(is(T == class)) { scope T payload; T borrow() return {// `return` applies to `this` return payload; } } ... Also, what exactly does the `scope` on T payload get you? It means if you forget the `return`

Re: The next iteration of scope

2015-03-16 Thread Zach the Mystic via Digitalmars-d
On Monday, 16 March 2015 at 13:55:43 UTC, Marc Schütz wrote: Also, what exactly does the `scope` on T payload get you? Is it just a more specific version of `return` on the this parameter, i.e. `return this.payload`? Why would you need that specificity? What is the dangerous operation it is

Re: The next iteration of scope

2015-03-16 Thread via Digitalmars-d
On Monday, 16 March 2015 at 15:25:45 UTC, Zach the Mystic wrote: If an RC'd struct is heap-allocated, but one of its members points to the stack, how is it ever safe to escape it? It isn't. Why shouldn't the heap variable be treated as scoped too, inheriting the most restricted scope of any

Re: The next iteration of scope

2015-03-16 Thread via Digitalmars-d
On Monday, 16 March 2015 at 13:55:43 UTC, Marc Schütz wrote: On Monday, 16 March 2015 at 04:00:51 UTC, Zach the Mystic wrote: Functions and methods can be overloaded on scope. This allows efficient passing of RC wrappers for instance... How does the compiler figure out which of the variables

Re: The next iteration of scope

2015-03-16 Thread via Digitalmars-d
On Monday, 16 March 2015 at 19:43:01 UTC, Zach the Mystic wrote: On Monday, 16 March 2015 at 17:00:12 UTC, Marc Schütz wrote: BUt there is indeed still some confusion on my side. It's about the question whether `this` should implicitly be passed as `scope` or not. Because if it is, scope

Re: The next iteration of scope

2015-03-16 Thread Zach the Mystic via Digitalmars-d
On Monday, 16 March 2015 at 17:00:12 UTC, Marc Schütz wrote: BUt there is indeed still some confusion on my side. It's about the question whether `this` should implicitly be passed as `scope` or not. Because if it is, scope members are probably useless, because they are already implied. I

The next iteration of scope

2015-03-15 Thread via Digitalmars-d
Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the implementation, and a more formal specification, as well as a discussion of backwards compatibility. But I thought I'd show what I have, so that it

Re: The next iteration of scope

2015-03-15 Thread Nick Treleaven via Digitalmars-d
On 15/03/2015 14:10, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the implementation, and a more formal specification, as well as a discussion of

Re: The next iteration of scope

2015-03-15 Thread via Digitalmars-d
On Sunday, 15 March 2015 at 17:31:17 UTC, Nick Treleaven wrote: On 15/03/2015 14:10, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the

Re: The next iteration of scope

2015-03-15 Thread Zach the Mystic via Digitalmars-d
On Sunday, 15 March 2015 at 14:10:02 UTC, Marc Schütz wrote: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 It's still missing real-life examples, a section on the implementation, and a more formal specification, as well as a discussion of backwards