Feedback on Átila's Vision for D

Atila Neves atila.neves at gmail.com
Wed Oct 16 15:59:36 UTC 2019


On Wednesday, 16 October 2019 at 15:39:21 UTC, John Colvin wrote:
> On Wednesday, 16 October 2019 at 11:08:18 UTC, Atila Neves 
> wrote:
>> On Wednesday, 16 October 2019 at 07:09:38 UTC, JN wrote:
>>> On Tuesday, 15 October 2019 at 16:17:57 UTC, Atila Neves 
>>> wrote:
>>>>
>>>> Meh:
>>>>
>>>> //C++20 concepts
>>>> concept isAddable = requires (T x) { x + x; };
>>>>
>>>> // D
>>>> enum isAddable(T) = is(typeof((T x) => x + x));
>>>>
>>>>
>>>> We lose by one character ;)
>>>
>>> I disagree. It's not just one character. C++ example is much 
>>> cleaner. Imagine not being experienced with C++ and D and 
>>> seeing these two examples.
>>
>> Ok:
>>
>> enum requires(alias F) = is(typeof(F));
>> enum isAddable(T) = requires!((T x) => x + x);
>> static assert(isAddable!int);
>
> static assert(!isAddable!string); doesn't work so nicely

Ugh, good point.


More information about the Digitalmars-d mailing list