www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.development - Second Draft: ref for Variable Declarations

reply Walter Bright <newshound2 digitalmars.com> writes:
https://github.com/WalterBright/documents/blob/01291980cbfd80b85575fc6f8ba44d0d433cd4f8/varRef.md

This is pretty much done.
May 02
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 3 May 2024 at 03:43:39 UTC, Walter Bright wrote:
 https://github.com/WalterBright/documents/blob/01291980cbfd80b85575fc6f8ba44d0d433cd4f8/varRef.md

 This is pretty much done.
This DIP has an implementation, you should link to it. Most of the `Rationale` section is exposition (describing existing behaviour), not rationale. The last line of the rationale is parenthetical to the abstract, not the rationale. The actual rationale (comments about the use of `ref` in `foreach`), should be written as stating the upside of the use of such `ref`s, not that no downsides exist. You should give examples as to times when you felt the feature should exist (or link to them elsewhere in the document) rather than assert they exist (with no evidence). You should include a diff of the relevant parts of there grammar (where appropriate). Your example that purports to show the utility of the new feature is already accomplishable by `alias` ```d void pop87(int line, const(char)* file) { alias g = global87; // ... use `g` ``` as noted by Rikki in the previous thread.
May 02
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 03/05/2024 4:19 PM, Nicholas Wilson wrote:
 Your example that purports to show the utility of the new feature is 
 already accomplishable by |alias|
 
 |void pop87(int line, const(char)* file) { alias g = global87; // ... 
 use `g` |
 
 as noted by Rikki in the previous thread.
I didn't know that it worked with same scope and was counter proposing expansion. But yeah it totally does. ```d import std; int global; void main() { int var; alias g = global; alias v = var; writeln(g, v); // 00 } ```
May 02
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/2/2024 9:19 PM, Nicholas Wilson wrote:
 Your example that purports to show the utility of the new feature is already 
 accomplishable by `alias`
 ```d
 void pop87(int line, const(char)* file)
 {
      alias g = global87;
      // ... use `g`
 ```
Not exactly. Accessing global variables takes a varying number of instructions depending on the memory model. Using a ref variable makes it a simple pointer. An alias is fundamentally different, although in trivial cases they can appear to be the same. There are three ways to refer to a value 1. by value 2. by reference 3. by name Alias is by name, you'll see it also in ref, alias, and value parameters to function templates.
May 03
parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 3 May 2024 at 07:57:34 UTC, Walter Bright wrote:
 Not exactly. Accessing global variables takes a varying number 
 of instructions depending on the memory model. Using a ref 
 variable makes it a simple pointer. An alias is fundamentally 
 different, although in trivial cases they can appear to be the 
 same.

 There are three ways to refer to a value

 1. by value
 2. by reference
 3. by name

 Alias is by name, you'll see it also in ref, alias, and value 
 parameters to function templates.
Then you should explain that in the DIP and use that to argue by access by name is undesirable compared to by ref (in whatever cases you add to prosecute the case for the DIP). All the DIP says at the moment is that "its can be done like this", it cites no additional logic as to why that is superior to option that currently work already in a syntactically analogous way.
May 03
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/2/2024 9:19 PM, Nicholas Wilson wrote:
 On Friday, 3 May 2024 at 03:43:39 UTC, Walter Bright wrote:
 https://github.com/WalterBright/documents/blob/01291980cbfd80b85575fc6f8ba44d0d433cd4f8/varRef.md

 This is pretty much done.
This DIP has an implementation, you should link to it.
Ok.
 Most of the `Rationale` section is exposition (describing existing behaviour), 
 not rationale. The last line of the rationale is parenthetical to the
abstract, 
 not the rationale. The actual rationale (comments about the use of `ref` in 
 `foreach`), should be written as stating the upside of the use of such `ref`s, 
 not that no downsides exist. You should give examples as to times when you
felt 
 the feature should exist (or link to them elsewhere in the document) rather
than 
 assert they exist (with no evidence).
You're right, but what is the point? Aren't they rather obvious? After all, we all have experience with ref parameters in D, and ref variables in foreach, that have the same purpose. Refs are well known and exist in other languages, like for is completely constrained by the behavior of the existing uses of ref.
 You should include a diff of the relevant parts of there grammar (where 
 appropriate).
There are no changes to the grammar. Ref locals were previously rejected in the semantic pass.
May 03
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 3 May 2024 at 08:08:13 UTC, Walter Bright wrote:
 You should include a diff of the relevant parts of there 
 grammar (where appropriate).
There are no changes to the grammar. Ref locals were previously rejected in the semantic pass.
Then you should note in the DIP that no changes to the grammar are needed.
May 03
parent Nick Treleaven <nick geany.org> writes:
On Friday, 3 May 2024 at 08:59:19 UTC, Nicholas Wilson wrote:
 Then you should note in the DIP that no changes to the grammar 
 are needed.
It's the first sentence of the description: https://github.com/WalterBright/documents/blob/01291980cbfd80b85575fc6f8ba44d0d433cd4f8/varRef.md#description
May 04
prev sibling parent Mike Parker <aldacron gmail.com> writes:
On Friday, 3 May 2024 at 03:43:39 UTC, Walter Bright wrote:

 This is pretty much done.
This DIP has been committed to the repository as DIP1046 and the review process is complete: https://github.com/dlang/DIPs/blob/a5b42f15e8c7b8d7b037465eba08d620c3f85198/DIPs/DIP1046.md Given that Walter is the author, I put the DIP on the agenda for our most recent monthly meeting and asked if there were any objections to submitting it to Atila for the formal assessment. No objections were raised. The following people were present for this portion of the meeting: Jonathan M. Davis Timon Gehr Martin Kinkelin Dennis Korpel Mathias Lang Mike Parker Robert Schadek Steven Schveighoffer Adam Wilson Thanks to everyone who left feedback in both review threads. Please do not comment further in this thread. If you'd like to say more, please start a new thread in the General forum.
May 21