www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - The RangeExpression

reply user1234 <user1234 12.de> writes:
Simple as

     Expression ".." Expression

Would simplify the grammar of the SwitchStatement, the 
ForeachStatement. Would open possibilities for operator 
overloading.
Nov 12
next sibling parent reply user1234 <user1234 12.de> writes:
On Wednesday, 12 November 2025 at 18:34:01 UTC, user1234 wrote:
 Simple as

     Expression ".." Expression

 Would simplify the grammar of the SwitchStatement, the 
 ForeachStatement. Would open possibilities for operator 
 overloading.
It's about https://wiki.dlang.org/DIP58 actually.
Nov 12
parent reply ltdk <khoa.alter.acc gmail.com> writes:
On Wednesday, 12 November 2025 at 18:38:06 UTC, user1234 wrote:
 On Wednesday, 12 November 2025 at 18:34:01 UTC, user1234 wrote:
 Simple as

     Expression ".." Expression

 Would simplify the grammar of the SwitchStatement, the 
 ForeachStatement. Would open possibilities for operator 
 overloading.
It's about https://wiki.dlang.org/DIP58 actually.
Oh, I really like it. Make tensor manipulation (pretty much anything related to ML/DL) more convenient.
Nov 12
parent reply Serg Gini <kornburn yandex.ru> writes:
On Thursday, 13 November 2025 at 03:11:36 UTC, ltdk wrote:
 Oh, I really like it. Make tensor manipulation (pretty much 
 anything related to ML/DL) more convenient.
Do you use D for tensor manipulations?
Nov 13
next sibling parent ltdk <khoa.alter.acc gmail.com> writes:
On Thursday, 13 November 2025 at 08:10:41 UTC, Serg Gini wrote:
 On Thursday, 13 November 2025 at 03:11:36 UTC, ltdk wrote:
 Oh, I really like it. Make tensor manipulation (pretty much 
 anything related to ML/DL) more convenient.
Do you use D for tensor manipulations?
recently, no .... I switched to Julia.
Nov 14
prev sibling parent jmh530 <john.michael.hall gmail.com> writes:
On Thursday, 13 November 2025 at 08:10:41 UTC, Serg Gini wrote:
 On Thursday, 13 November 2025 at 03:11:36 UTC, ltdk wrote:
 Oh, I really like it. Make tensor manipulation (pretty much 
 anything related to ML/DL) more convenient.
Do you use D for tensor manipulations?
Doesn't have to mean tensors per se. D's built-in arrays and mir's ndslice and any other similar projects would benefit from something like this.
Nov 14
prev sibling parent user1234 <user1234 12.de> writes:
On Wednesday, 12 November 2025 at 18:34:01 UTC, user1234 wrote:
 Simple as

     Expression ".." Expression

 Would simplify the grammar of the SwitchStatement, the 
 ForeachStatement. Would open possibilities for operator 
 overloading.
foreach over ranges is really special: ```d int[] a; foreach( i; mixin("a") ) {} foreach( i; mixin("0 .. 100") ) {} // whoops ``` The problem however would be that the RangeExpression is an internal compiler thing because it has no storage, example of problematic uses: ```d auto b = a .. c; call(a .. z); ``` But you want them to be expressions anyway ```d void v(alias T)(a) { switch (a){ case T: break; default: assert(0); } } v!(0..10)(rand()); ``` So you're a bit between a macro and an expression. The D way for macro is mixin, but here that does not work.
Nov 12