opConcatAll?

Steven Schveighoffer schveiguy at gmail.com
Fri Jul 3 18:07:08 UTC 2020


On 7/3/20 1:54 PM, jmh530 wrote:
> On Friday, 3 July 2020 at 17:13:32 UTC, Steven Schveighoffer wrote:
>> [snip]
>>
>> Meh, the user can do anything he wants already. One can get around 
>> precedence by deferring calls.
>>
>> It is true, though, that I didn't think of precedence when I first 
>> posted -- I just wanted to avoid some allocations.
>>
> 
> I see no reason why Aliak's suggestion above with respect to parentheses 
> cannot be also used to ensure precedence is followed. For instance, if 
> you have a + b * c, then it gets re-written to a + (b * c), which gets 
> re-written to something like a.op1(b.op2(c)).

That's what's already done today.

The idea here is to pass all the operations and parameters at once. 
There are actually advantages in some cases to have the entire 
expression, as some things could be optimized by reordering operations 
(in a valid way).

The further question of this subthread is -- can we loosen some of the 
precedence rules so this provides more capabilities, or would it be 
crippled by enforcing precedence rules?

-Steve


More information about the Digitalmars-d mailing list