opConcatAll?

Petar Petar
Fri Jul 3 18:41:56 UTC 2020


On Friday, 3 July 2020 at 15:39:08 UTC, Andrei Alexandrescu wrote:
> On 7/3/20 3:17 AM, Petar Kirov [ZombineDev] wrote:
>> [..]
>> 
>> We kind of have this already, but a bit closer to what jmh was 
>> describing earlier.
>> Though it's just an implementation detail inside druntime for 
>> implementing array ops:
>> 
>> https://github.com/dlang/druntime/blob/v2.092.1/src/core/internal/array/operations.d#L15-L36
>> 
>> 
>> I think that it would be pretty cool if this technique could 
>> be applied to user-defined types (e.g. allow library authors 
>> to provide their own `arrayOp` implementation of their types).
>
> How are parens handled?

Parens don't need special handling since they're already handled 
by the dmd parser. The frontend simply traverses the expression 
tree for the array op and outputs it in reverse polish notation 
here: 
https://github.com/dlang/dmd/blob/v2.092.1/src/dmd/arrayop.d#L180-L255

For reference, here's the PR by Martin Nowak, who implemented 
this: https://github.com/dlang/dmd/pull/7032


More information about the Digitalmars-d mailing list