Flag proposal

Michel Fortin michel.fortin at michelf.com
Fri Jun 10 15:25:39 PDT 2011


On 2011-06-10 17:04:42 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 6/10/11 3:34 PM, Michel Fortin wrote:
>> If you want something to be used everywhere and it is not an
>> implementation detail, make it part of the language. Implementing what
>> sounds should be a language feature through a template hack and putting
>> it the standard library is not going to make people feel good about the
>> language, it'll remind them of what the language is missing.
> 
> The problem with the "hack" label is that it instantly decreases the 
> level of the conversation. It's the "N" word of programming.

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.


> I don't want a universal thing, I want to solve a simple problem: there 
> are 7 yes/no enums in Phobos, and probably some more to come. Flag 
> solves that problem in a reasonable way. This is pretty much it.

I disagree that Flag is a reasonable solution. It works, but it's ugly 
and verbose. I understand it's tiresome to create an enum for every 
parameter, but asking all users to write Flag!"" everywhere is going to 
be tiresome everywhere else, which is hardly an improvement.

I also think you are narrowing the problem a little too much. The 
problem exists everywhere there is a boolean parameter. This includes 
phobos, druntime, and potentially any other D library. Should Flag!"" 
become the recommended way to make boolean parameters in D? And should 
creating a separate Ddoc version of the function signature become the 
recommended way to document boolean parameters? If so, I think it'll 
reflect badly on the language.


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



More information about the Digitalmars-d mailing list