Feedback Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1

Q. Schroll qs.il.paperinik at gmail.com
Wed Oct 28 01:32:59 UTC 2020


The tuple expansion is great, I love it. Its missing from the 
language far too long.

Personally, I find the DIP addresses the lesser of the two 
important use cases of expansion. Expression tuple expansion is a 
thing to want, but type tuple expansion is more to want.
With that DIP, it is still not possible to get from a 
AliasSeq!(int, long, Foo) to AliasSeq!(Array!int, Array!long, 
Array!Foo).

The DIP should therefore expand the proposal to type contexts.

Also, I find it should be possible to hook that operator. 
opExpand would be my name of choice. Basically, the DIP should 
include that when the `...` operator is "pushed down" the 
expression tree, when it hits a subexpression E such that 
E.opExpand compiles, it should use it as a sequence. As an 
example, if xs is a sequence (say, xs == AliasSeq!(1,2,3) for 
example) and ys is of some type that defines opExpand (alias 
opExpand = AliasSeq!("a","b","c"); for example), then (ys[xs])... 
expands into (ys.opExpand[0][xs[0]], ys.opExpand[1][xs[1]], 
ys.opExpand[2][xs[2]]). That way, tuples could be expanded 
without need to `alias this` to the underlying fields, making it 
possible to have them encapsulated.


More information about the Digitalmars-d mailing list