digitalmars.D - `in` no longer same as `const ref`
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/2) Jan 29 2017 https://github.com/dlang/druntime/pull/1748/files
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/5) Jan 29 2017 Correction:
- Walter Bright (3/4) Jan 29 2017 Because it was unchecked and largely unimplemented. I was afraid that by...
- =?UTF-8?B?Tm9yZGzDtnc=?= (2/6) Jan 29 2017 Will we make them equal in the long run? So much shorter to read.
- Walter Bright (2/3) Jan 30 2017 I know it's shorter. I'd like to do it too, we'll have to see.
- Radu (7/11) Jan 30 2017 Can it be enabled for -dip1000 flag?
- Walter Bright (2/7) Jan 30 2017 I'd rather do one thing at a time.
- =?UTF-8?B?Tm9yZGzDtnc=?= (9/10) Jan 30 2017 +1
- Walter Bright (3/9) Jan 30 2017 It's what I plan to talk about at DConf.
- Jonathan M Davis via Digitalmars-d (12/16) Jan 29 2017 Which is why I've been arguing against anyone using in for years, but so...
- Olivier FAURE (5/11) Jan 30 2017 I've always thought of 'in' as a visual shorthand for "this
- Q. Schroll (12/24) Jan 30 2017 Would have been a far better definition. Why does anyone really
- bitwise (9/15) Jan 30 2017 'ref' being separate from 'in' allows you to use both:
- kinke (10/16) Jan 30 2017 +1000, I really love this proposal; I *hate* that this point is
- Chris Wright (3/5) Jan 30 2017 Because there was existing code thath used `in` and `scope const` was th...
- Adam D. Ruppe (4/5) Jan 30 2017 Code that was using it improperly was *already* broken. Now, the
- Olivier FAURE (6/11) Jan 30 2017 Well, it's a trade-off. Some people would rather their project
- Soulsbane (5/9) Jan 30 2017 Unless I'm completely missing something the documentation still
https://github.com/dlang/druntime/pull/1748/files Why is `in` no longer the same as `const ref`?
Jan 29 2017
On Sunday, 29 January 2017 at 11:49:19 UTC, Nordlöw wrote:https://github.com/dlang/druntime/pull/1748/files Why is `in` no longer the same as `const ref`?Correction: Why is `in` no longer the same as `const scope`?
Jan 29 2017
On 1/29/2017 3:50 AM, Nordlöw wrote:Why is `in` no longer the same as `const scope`?Because it was unchecked and largely unimplemented. I was afraid that by checking it, too much code would break.
Jan 29 2017
On Monday, 30 January 2017 at 00:26:27 UTC, Walter Bright wrote:On 1/29/2017 3:50 AM, Nordlöw wrote:Will we make them equal in the long run? So much shorter to read.Why is `in` no longer the same as `const scope`?Because it was unchecked and largely unimplemented. I was afraid that by checking it, too much code would break.
Jan 29 2017
On 1/29/2017 9:50 PM, Nordlöw wrote:Will we make them equal in the long run? So much shorter to read.I know it's shorter. I'd like to do it too, we'll have to see.
Jan 30 2017
On Monday, 30 January 2017 at 08:02:12 UTC, Walter Bright wrote:On 1/29/2017 9:50 PM, Nordlöw wrote:Can it be enabled for -dip1000 flag? Doc was pretty clear on what it was suppose to do and people kinda knew that scope was not finished. Having it turned on for dip flag will allow some testing of the existing code. I would like to have in's intended semantic finally implemented.Will we make them equal in the long run? So much shorter to read.I know it's shorter. I'd like to do it too, we'll have to see.
Jan 30 2017
On 1/30/2017 12:42 AM, Radu wrote:Can it be enabled for -dip1000 flag? Doc was pretty clear on what it was suppose to do and people kinda knew that scope was not finished. Having it turned on for dip flag will allow some testing of the existing code. I would like to have in's intended semantic finally implemented.I'd rather do one thing at a time.
Jan 30 2017
On Monday, 30 January 2017 at 11:32:11 UTC, Walter Bright wrote:I'd rather do one thing at a time.+1 And it won't be too difficult to search-and-replace `const scope` with `in` once things has stabilized and all the corner cases have been sorted out. Thanks for making D more safe, Walter. D really needs it in the competition with Rust. Once things have stabilized we really need to announce this work and highlight its developer productivity compared to Rust.
Jan 30 2017
On 1/30/2017 7:06 AM, Nordlöw wrote:And it won't be too difficult to search-and-replace `const scope` with `in` once things has stabilized and all the corner cases have been sorted out. Thanks for making D more safe, Walter. D really needs it in the competition with Rust.You're welcome.Once things have stabilized we really need to announce this work and highlight its developer productivity compared to Rust.It's what I plan to talk about at DConf.
Jan 30 2017
On Sunday, January 29, 2017 16:26:27 Walter Bright via Digitalmars-d wrote:On 1/29/2017 3:50 AM, Nordlöw wrote:Which is why I've been arguing against anyone using in for years, but some folks really liked how it was a parallel of out and used it anyway. Some understood what scope was at least theoretically supposed to mean and were willing to deal with the consequences if and when scope were actually implemented beyond delegates, but most just used it without that understanding. Personally, I think that effectively having an alias for two attributes in a single attribute is a confusing design decision anyway and think that it was a mistake, but we've had folks slapping in on stuff for years with no enforcement, and flipping the switch on that would likely not be pretty. - Jonathan M DavisWhy is `in` no longer the same as `const scope`?Because it was unchecked and largely unimplemented. I was afraid that by checking it, too much code would break.
Jan 29 2017
On Monday, 30 January 2017 at 06:38:11 UTC, Jonathan M Davis wrote:Personally, I think that effectively having an alias for two attributes in a single attribute is a confusing design decision anyway and think that it was a mistake, but we've had folks slapping in on stuff for years with no enforcement, and flipping the switch on that would likely not be pretty. - Jonathan M DavisI've always thought of 'in' as a visual shorthand for "this parameter doesn't care whether you give it a deep copy or a shallow reference", personally.
Jan 30 2017
On Monday, 30 January 2017 at 12:08:06 UTC, Olivier FAURE wrote:On Monday, 30 January 2017 at 06:38:11 UTC, Jonathan M Davis wrote:Would have been a far better definition. Why does anyone really need a shorthand attribute for two attributes that could be easily spelled out? You can type anything for "const scope" while programming and then do search-and-replace. That's even trivial. Can't we make "in" mean "const scope ref", that binds on r-values, too? Effectively, that's (similar to) what "const T&" in C++ means. It's a non-copying const view on the object. We have the longstanding problem, one must overload a function to effectively bind both l- and r-values. That is what I'd suppose to be the dual to "out".Personally, I think that effectively having an alias for two attributes in a single attribute is a confusing design decision anyway and think that it was a mistake, but we've had folks slapping in on stuff for years with no enforcement, and flipping the switch on that would likely not be pretty. - Jonathan M DavisI've always thought of 'in' as a visual shorthand for "this parameter doesn't care whether you give it a deep copy or a shallow reference", personally.
Jan 30 2017
On Monday, 30 January 2017 at 19:05:33 UTC, Q. Schroll wrote:Can't we make "in" mean "const scope ref", that binds on r-values, too? Effectively, that's (similar to) what "const T&" in C++ means. It's a non-copying const view on the object.'ref' being separate from 'in' allows you to use both: foo(in ref T x); foo(in T* x); However, I agree that 'in' should be the opposite of 'out' (const scope ref). Making the 'in' and 'out' keywords semantically asymmetrical just to save a few key strokes is dumb.We have the longstanding problem, one must overload a function to effectively bind both l- and r-values. That is what I'd suppose to be the dual to "out".+1 on allowing rvalue to bind to 'const scope ref'...or 'in' done right.
Jan 30 2017
On Monday, 30 January 2017 at 19:05:33 UTC, Q. Schroll wrote:Can't we make "in" mean "const scope ref", that binds on r-values, too? Effectively, that's (similar to) what "const T&" in C++ means. It's a non-copying const view on the object. We have the longstanding problem, one must overload a function to effectively bind both l- and r-values. That is what I'd suppose to be the dual to "out".+1000, I really love this proposal; I *hate* that this point is still missing in D in 2017. It shouldn't even break existing code using `in` (but obviously the ABI) just because now a pointer to a const instance is passed instead of making a const copy. Generic stuff: void foo(in T arg) // const scope ref => safe `const T&` By-value optimizations: void foo(const T arg) I love it.
Jan 30 2017
On Mon, 30 Jan 2017 19:05:33 +0000, Q. Schroll wrote:Would have been a far better definition. Why does anyone really need a shorthand attribute for two attributes that could be easily spelled out?Because there was existing code thath used `in` and `scope const` was the nearest equivalent.
Jan 30 2017
On Monday, 30 January 2017 at 00:26:27 UTC, Walter Bright wrote:I was afraid that by checking it, too much code would break.Code that was using it improperly was *already* broken. Now, the compiler will simply tell them, at compile time, why instead of letting it silently accept undefined behavior.
Jan 30 2017
On Monday, 30 January 2017 at 13:57:10 UTC, Adam D. Ruppe wrote:On Monday, 30 January 2017 at 00:26:27 UTC, Walter Bright wrote:Well, it's a trade-off. Some people would rather their project with potentially broken code does not stop compiling because they upgraded their compiler. Although I guess you could solve this by having -dip1000 emit only warnings and no error until the adaptation period had passed.I was afraid that by checking it, too much code would break.Code that was using it improperly was *already* broken. Now, the compiler will simply tell them, at compile time, why instead of letting it silently accept undefined behavior.
Jan 30 2017
On Monday, 30 January 2017 at 00:26:27 UTC, Walter Bright wrote:On 1/29/2017 3:50 AM, Nordlöw wrote:Unless I'm completely missing something the documentation still says: http://dlang.org/spec/function.html#parameters in equivalent to const scopeWhy is `in` no longer the same as `const scope`?Because it was unchecked and largely unimplemented. I was afraid that by checking it, too much code would break.
Jan 30 2017