[OT] Modules dropped out of C++17

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 16:09:19 PDT 2015


On 06/09/2015 06:27 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= 
<schuetzm at gmx.net>" wrote:
> On Tuesday, 9 June 2015 at 15:49:07 UTC, Timon Gehr wrote:
>> On 06/09/2015 02:28 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?=
>> <schuetzm at gmx.net>" wrote:
>>> On Tuesday, 9 June 2015 at 11:47:49 UTC, Kagamin wrote:
>>>> On Tuesday, 9 June 2015 at 10:48:22 UTC, Marc Schütz wrote:
>>>>> static assert() is your friend in this case
>>>>
>>>> The point is that in D you don't need to express ctfe guarantee at
>>>> all. It just works.
>>>
>>> Huh? As I understood you, you asked for a guarantee that a function is
>>> CTFEable, in order to "not break other people's code". static assert()
>>> gives you that:
>>>
>>>     static assert(__traits(compiles, { enum dummy = myFunction(); }));
>>
>> What if you don't support it, but it works by accident?
>
> If you don't want to support it, why _would_ you put the static assert()
> in? Or do you mean something else?

Basically, the scenario that *lack* of constexpr is able to successfully 
avoid by default is that you write a function that just so happens to 
work in CTFE but doesn't in the next release, and your dependencies 
break (in D you'd need to add an explicit if(__ctfe) assert(0), or 
similar.) I.e. lack of constexpr is a kind of enforced documentation. 
Anyway, I don't think this is worth the additional trouble.


More information about the Digitalmars-d mailing list