Thread overview
RFC: 2 enhancement DIPs that need feedback
4 days ago
Meta
4 days ago
Monkyyy
4 days ago
Meta
3 days ago
Basile B.
2 days ago
Timon Gehr
13 hours ago
Basile B.
8 hours ago
Timon Gehr
8 hours ago
Timon Gehr
3 hours ago
Basile B.
4 days ago

Hello, I've been working on a couple different DIPs that propose various enhancements to D.

  1. Implicit Type Template Instantiation via Constructors with Dennis Korpel:
    https://forum.dlang.org/post/wxfvbvutqjwvfrvuksua@forum.dlang.org

  2. Tuple Unpacking Syntax with Timon Gehr and Nick Trealeven:
    https://forum.dlang.org/post/mjzhwbwuvnfqimwazzxq@forum.dlang.org

DIP 1 has gotten a little bit of feedback, but not much, and DIP 2 was just posted today. If you have an interest in either of these features and want to see them in D, it would be greatly appreciated if you could leave comments in either thread so we can get a feel for whether these DIPs are worth pushing through the proposal process.

Note that DIP 1 is in the DIP Drafts forum, and DIP 2 is in the DIP Ideas forum. The regular rules regarding feedback on DIPs in each forum apply.

Without adequate feedback, they will likely not move forward, so please read them over and leave any thoughts you might have!

Thank you.

4 days ago

On Monday, 12 May 2025 at 23:13:23 UTC, Meta wrote:

>

Hello, I've been working on a couple different DIPs that propose various enhancements to D.

[...]

I think dip 2 is far more important, dip 1 has work arounds and I dislike the complexity around constructors as is

4 days ago

On Monday, 12 May 2025 at 23:23:27 UTC, Monkyyy wrote:

>

On Monday, 12 May 2025 at 23:13:23 UTC, Meta wrote:

>

Hello, I've been working on a couple different DIPs that propose various enhancements to D.

[...]

I think dip 2 is far more important, dip 1 has work arounds and I dislike the complexity around constructors as is

Please leave your feedback in the respective threads I linked. Thank you!

3 days ago

On Monday, 12 May 2025 at 23:29:36 UTC, Meta wrote:

>

On Monday, 12 May 2025 at 23:23:27 UTC, Monkyyy wrote:

>

On Monday, 12 May 2025 at 23:13:23 UTC, Meta wrote:

>

Hello, I've been working on a couple different DIPs that propose various enhancements to D.

[...]

I think dip 2 is far more important, dip 1 has work arounds and I dislike the complexity around constructors as is

Please leave your feedback in the respective threads I linked. Thank you!

I'll drop a comment here anyway because it doesn't fit to the DIP section I think.

D really needs "variable declaration" as expressions. My opinion is that here you are again faced to a special case that the general case, i.e "variable declaration" as expression, would have solved.

(auto a, auto b) = call(); // two VarDeclExp in the LHS

Let me enumerate all the cases we have now. You can exceptionally declare variable as expression in

  • the IfStatement
  • the WithStatement
  • the WhileStatement
  • the SwitchStatement

and now what is proposed is another case: as tuple element.

Cant just people open their eyes ? That language construct tends to become a well defined expression.

A little joke to finish, I occasionally use that thing to count if something new is worth:

printf("for the %dnth time\n", static int count++);

Yeah that kind of things work when you have "variable declaration" as expression.

2 days ago
On 5/13/25 11:04, Basile B. wrote:
> On Monday, 12 May 2025 at 23:29:36 UTC, Meta wrote:
>> On Monday, 12 May 2025 at 23:23:27 UTC, Monkyyy wrote:
>>> On Monday, 12 May 2025 at 23:13:23 UTC, Meta wrote:
>>>> Hello, I've been working on a couple different DIPs that propose various enhancements to D.
>>>>
>>>> [...]
>>>
>>> I think dip 2 is far more important, dip 1 has work arounds and I dislike the complexity around constructors as is
>>
>> Please leave your feedback in the respective threads I linked. Thank you!
> 
> I'll drop a comment here anyway because it doesn't fit to the DIP section I think.
> 
> D really needs "variable declaration" as expressions. My opinion is that here you are again faced to a special case that the general case, i.e "variable declaration" as expression, would have solved.
> 
> ```d
> (auto a, auto b) = call(); // two VarDeclExp in the LHS
> ```
> ...

No, this syntax would not work just because there would be variable declaration as expression. You still need a) tuple literals b) dedicated unpacking logic.


> Let me enumerate all the cases we have now. You can exceptionally declare variable as expression in
> 
> - the IfStatement
> - the WithStatement
> - the WhileStatement
> - the SwitchStatement
> 
> and now what is proposed is another case: as tuple element.
> ...

Actually that is not true. The DIP does not propose dedicated tuple syntax to be added. It's just about unpacking. Anyway, it's not like that blocks work on your vision at all.

> Cant just people open their eyes ? That language construct tends to become a well defined expression.
> 
> A little joke to finish, I occasionally use that thing to count if something new is worth:
> 
> ```d
> printf("for the %dnth time\n", static int count++);
> ```
> 
> Yeah that kind of things work when you have "variable declaration" as expression.

Go ahead and implement it. It's harder, not a simplification. Suddenly, whenever you are parsing any expression, you will have to take into account the possibility that it is actually a variable declaration. The way DMD deals with lvalues is also ill-equipped to allow this to be added easily. Furthermore, you now have to do proper scope handling for short-circuiting operations.
13 hours ago

On Wednesday, 14 May 2025 at 16:56:23 UTC, Timon Gehr wrote:

>

On 5/13/25 11:04, Basile B. wrote:

>

[...]

No, this syntax would not work just because there would be variable declaration as expression. You still need a) tuple literals b) dedicated unpacking logic.

>

[...]

Actually that is not true. The DIP does not propose dedicated tuple syntax to be added. It's just about unpacking. Anyway, it's not like that blocks work on your vision at all.

>

[...]

Go ahead and implement it. It's harder, not a simplification. Suddenly, whenever you are parsing any expression, you will have to take into account the possibility that it is actually a variable declaration. The way DMD deals with lvalues is also ill-equipped to allow this to be added easily. Furthermore, you now have to do proper scope handling for short-circuiting operations.

It is implemented but not in D.

I see what would be the problem with D or rather I see what "you guys think" the problem would be. I think that this is wrong, it's not like if the parser does not already have to perform an arbitrary count of lookups in certain situations.

8 hours ago
On 5/16/25 13:24, Basile B. wrote:
> On Wednesday, 14 May 2025 at 16:56:23 UTC, Timon Gehr wrote:
>> On 5/13/25 11:04, Basile B. wrote:
>>> [...]
>>
>> No, this syntax would not work just because there would be variable declaration as expression. You still need a) tuple literals b) dedicated unpacking logic.
>>
>>
>>> [...]
>>
>> Actually that is not true. The DIP does not propose dedicated tuple syntax to be added. It's just about unpacking. Anyway, it's not like that blocks work on your vision at all.
>>
>>> [...]
>>
>> Go ahead and implement it. It's harder, not a simplification. Suddenly, whenever you are parsing any expression, you will have to take into account the possibility that it is actually a variable declaration. The way DMD deals with lvalues is also ill-equipped to allow this to be added easily. Furthermore, you now have to do proper scope handling for short-circuiting operations.
> 
> It **is** implemented but not in **D**.
> ...

I don't know why you seem to think I am not aware of this.

Clearly I meant go ahead and implement it in DMD, and deal with the politics and technical debt, in addition to refactoring an evolving code base that was not originally developed with this feature in mind.

I don't think it is a bad idea, it's just not what I had chosen to invest my increasingly scarce spare time in. IIRC Andrei also wanted this, so I don't think it is impossible for this to make it into the language.

It's just that my analysis of the cost/benefit ratio makes this an unappealing prospect to me at the moment.

> I see what would be the problem with D or rather I see what "you guys think" the problem would be. I think that this is wrong, it's not like if the parser does not already have to perform an arbitrary count of lookups in certain situations.

There is no fundamental problem, given infinite resources. I just went with a less controversial incremental language addition that was also simple enough to implement and improves language ergonomics meaningfully.

Anyway, I don't understand why you are approaching this in such a belligerent manner. (My eyes are open, thank you very much, it seems that did not magically implement your feature in DMD though.) Just understand we have to start somewhere and I am not willing to maintain my own fork of the language indefinitely until it reaches your arbitrary standard of orthogonality of features.

Again, tuple unpacking does not conflict at all with variable declarations within expressions, and variable declarations within expressions, even if you add tuple literals with dedicated unpacking assignment logic, actually do not directly cover key use cases such as unpacking a foreach loop variable, unpacking at global scope, or unpacking in a function argument list.

So again, you are just asking: "Why did you not do significantly more work to also cover use cases like `if((auto a = foo()) && a.bar()){}` ?"

It's not hard to understand why I did not do it, it's basic economics. x) The unpacking DIP would not even be in the state it is now without Meta and Nick stepping up to help push it over the finish line. I did the basic implementation of UnpackDeclaration in _2018_! It's about time for this feature to land, and I am not going to entertain the idea of delaying it just because you seem to think rewriting big portions of DMD would have been so much easier.
8 hours ago
On 5/16/25 18:32, Timon Gehr wrote:
> I am not going to entertain the idea of delaying it just because you seem to think rewriting big portions of DMD would have been so much easier.

Even just getting tuple assignment to work is annoying:
https://github.com/tgehr/dmd/pull/12#pullrequestreview-2779380671

Feel free to fix the limitations of that PR, I think it's a necessary prerequisite to supporting tuple unpacking via variable declaration as expression.
3 hours ago

On Friday, 16 May 2025 at 16:43:05 UTC, Timon Gehr wrote:

>

On 5/16/25 18:32, Timon Gehr wrote:

>

I am not going to entertain the idea of delaying it just because you seem to think rewriting big portions of DMD would have been so much easier.

Even just getting tuple assignment to work is annoying:
https://github.com/tgehr/dmd/pull/12#pullrequestreview-2779380671

Feel free to fix the limitations of that PR, I think it's a necessary prerequisite to supporting tuple unpacking via variable declaration as expression.

You really dont seem to get the point I tried to raise. It's not directly about tuples. It's about the fact that variable declarations as expressions would solve the problem directly. Bonus that would make the grammar much more simple for plenty of Statements. That's just astonishing how people refuse to see that.

I mean, are you (plurally) blind ?