Renaming Flag!"" in API

FreeSlave freeslave93 at gmail.com
Mon Oct 12 10:24:44 UTC 2020


Let's say I use Flag type named 'myflagname' in API like this:

import std.typecons;

void func(Flag!"myflagname" flag)
{
//...
}

void main()
{
     func(Yes.myflagname);
}

Later I realize that 'myflagname' is a bad name and I want to 
change it to something else. But if I do so, I break the existing 
code using this API as Flag with different name will be a 
different type and Yes.myflagname and No.myflagname won't fit in. 
I can't use alias as Yes and No relies on string literal.
Can this issue overcome somehow? Looks like a fundamental flaw 
with std.typecons.Flag.


More information about the Digitalmars-d-learn mailing list