Flag proposal

Michel Fortin michel.fortin at michelf.com
Fri Jun 10 18:08:09 PDT 2011


On 2011-06-10 18:57:20 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 6/10/11 5:25 PM, Michel Fortin wrote:
>> A hack is something that works even though it's ugly and generally cause
>> people to call for something better. I'm not opposed to using hacks as
>> long as they're well-encapsulated and not too fragile, but in this case
>> I find the encapsulation is leaky since you need to litter your code
>> with Flag!"" everywhere.
> 
> https://github.com/andralex/phobos/commit/84c75336a4ef04b4c3b1924d7ac9329e744ab8e7

It's 
> 
still a hack, but I'll agree it makes the encapsulation a little better 
if you use yes!"abc" at the function call point.

However, I still think it's a deterioration from the user's point of 
view compared to the current situation with hand-crafted enums: it 
still requires a string, and the documentation will say func(Flag!"abc" 
abc), repeating the parameter's name unless you hand-craft a special 
Ddoc version of the function declaration. It's better than 
Flag!"abc".yes, but it's worse than Abc.yes.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list