Feedback Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1
Paul Backus
snarwin at gmail.com
Tue Oct 27 16:16:51 UTC 2020
On Tuesday, 27 October 2020 at 10:54:46 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community
> Review of DIP 1037, "Add Unary Operator ...".
Given the map form, `expr ...`, it seems like it would be quite
easy to implement the fold form, `expr BinOp ...`, using only
library code. For example, the example in the DIP:
(Tup == 10) || ...
Could also be written as
any(only(Tup == 10 ...))
Or without Phobos:
bool any(bool args[]...)
{
bool result = false;
foreach (arg; args)
result ||= arg;
return result;
}
any(Tup == 10 ...)
The library versions require at worst O(1) template
instantiations, and have the advantage that they are not limited
to built-in operators. What are the advantages of `expr BinOp
...` compared to this approach?
More information about the Digitalmars-d
mailing list