Help needed: immutable struct is a type modifier, and that's wrong and broken

RazvanN razvan.nitu1305 at gmail.com
Thu Apr 16 06:09:46 UTC 2020


On Thursday, 16 April 2020 at 06:05:12 UTC, RazvanN wrote:
> 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.

Oh I see your point now. In the above example S and T are the 
same type because `immutable immutable S` == `immutable S`. 
Right, but the fact that an immutably defined struct cannot be 
stripped of it's qualifier brings some complications here.

Anyway, the fact that T is not equal to S is definitely a bug in 
this situation.


More information about the Digitalmars-d mailing list