Compile time values & implicit conditional mixin, as an alternative to tertiary operator hell and one-compile-time functions.

Paul Backus snarwin at gmail.com
Sun Jan 17 01:51:21 UTC 2021


On Sunday, 17 January 2021 at 00:28:02 UTC, Paul wrote:
> On Saturday, 16 January 2021 at 16:23:18 UTC, Paul Backus wrote:
>> This is true no matter what you do, because `enum` constants 
>> are immutable. Their value has to be computed in a single 
>> expression, and once assigned, it can never change.
>
> Wouldn't it make sense to also have a mutable compile time 
> variable though?
> I don't know about implimentation etc, but semantically I find 
> it strange there isn't.
> (Instead of running 'normal' code to retrieve a value from it 
> to be assigned to an enum constant since it couldnt be made 
> from the get go)

Why add a dedicated new language feature if you can get the same 
behavior "for free" using regular old functions together with 
CTFE? D is already a pretty complex language, after all.


More information about the Digitalmars-d mailing list