Challenge: Motivating examples for ...
Steven Schveighoffer
schveiguy at gmail.com
Sat Apr 25 15:17:35 UTC 2020
On 4/24/20 5:26 PM, Walter Bright wrote:
> On 4/22/2020 5:04 AM, Manu wrote:
>> [...]
>
> The examples in the DIP are, frankly, too trivial to make a case for the
> ... feature.
>
> So here's the challenge to everyone: a small (5?) collection of
> non-trivial motivating examples that show how it is done in D today, and
> how it is done with ...., and how much better the ... is.
also note, we can obsolete std.meta.anySatisfy or std.meta.allSatisfy,
as we can use CTFE and ... expressions to do the same thing:
enum orig = anySatisfy!(someTemplate, someList);
enum changed = [someTemplate!(someList)...].any(true);
I propose a function any which takes a range and returns true if any
element matches the provided one. And another one all(val) which does
the same if all are the value. This gives us maximum flexibility.
Not only that, but that pattern can be used without temporary little
`someTemplate` things, which are inevitably needed for anySatisfy.
If you look in my NoDuplicates example, I have used this pattern like:
static if([__traits(isSame, tuple, elem)...].any(true));
No templates needed.
-Steve
More information about the Digitalmars-d
mailing list