Help needed: immutable struct is a type modifier, and that's wrong and broken
RazvanN
razvan.nitu1305 at gmail.com
Thu Apr 16 06:05:12 UTC 2020
On Thursday, 16 April 2020 at 04:28:35 UTC, Timon Gehr wrote:
> On 16.04.20 05:55, RazvanN wrote:
>>
>>
>> Additionally, I think that
>>
>> static if(is(S == immutable T, T))
>>
>> should also not pass.
>>
>> The correct form should be
>>
>> static if(is(S == immutable))
>>
>> This way you express the fact that S is an immutably defined
>> type (with a storage specifier), whereas in the first case you
>> test if S is an immutably declared type (with a type
>> constructor).
>
> So the proposal is to turn `is` into an even more convoluted
> mess? :)
>
> Why should it even be possible to test for `immutable` on the
> declaration? That seems like an implementation detail as the
> only thing it achieves is that all members are marked that way.
I agree that this is kind of awkward, but things are confusing
otherwise.
Do you agree that in this situation `static if (is(S == immutable
T, T))` should not pass? Or should it pass and the `static
assert(is(S == T))` should also pass? In that case, T should bind
to an empty type, which D, as far as I know does not support at
the moment.
More information about the Digitalmars-d
mailing list