opConcatAll?

Simen Kjærås simen.kjaras at gmail.com
Sat Jul 4 06:28:15 UTC 2020


On Friday, 3 July 2020 at 19:06:21 UTC, Ali Çehreli wrote:
> On 7/2/20 12:28 PM, Nick Treleaven wrote:
>
> > Sounds good, although I think multiple other operations beside
> > concatenation could benefit from being intercepted:
> >
> > opNary(string op, T...)(T args)
>
> Given the confusions raised elsewhere in this thread, I think 
> that syntax gives the biggest benefit; defined for a single 
> operator. And we don't even need a new keyword:
>
>   opBinary(string op, T...)(T args)

That already has a defined behavior:

alias AliasSeq(T...) = T;

struct S {
     AliasSeq!(int, int, int) fields;
     void opBinary(string op, T...)(T args) {
         pragma(msg, T); // (int, int, int)
     }
}

unittest {
     S s;
     s + s.fields;
}

--
   Simen


More information about the Digitalmars-d mailing list