Against enforce()

Don nospam at nospam.com
Thu Mar 17 09:15:56 PDT 2011


Steven Schveighoffer wrote:
> On Wed, 16 Mar 2011 21:07:54 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>> On 03/16/2011 06:45 PM, bearophile wrote:
>>> - It kills inlining (with the current DMD, and I don't think this 
>>> problem will be fixed soon);
>>
>> Not a problem of enforce.
>>
> 
> Why can't enforce be this:
> 
> T enforce(T, string file = __FILE__, int line = __LINE__)(T value, /* lazy
> -- BUG: disables inlining */ const(char)[] msg = null);
> 
> Until the compiler is fixed?  I bet it would perform better even though
> the message may be eagerly constructed.  Simply because in 99% of cases
> (I've checked) the message is a string literal.
> 
> Essentially we keep saying D is on par with C for performance, and then
> the standard library is riddled with un-optimizable code making that claim
> patently false.  It doesn't help to say, "well yeah, I know it's not *now*
> but trust me, we know what the problem is and we'll fix it in the next
> 1-60 months."

I completely agree. If we make statements like "it's OK because it will 
be fixed soon" it has to be added to a list and prioritized. With the 
understanding that *it knocks something else from that list*. As I've 
ended up being the one who implements a large fraction of such things, I 
get unhappy when people casually make statements about them being 
implemented "soon".


More information about the Digitalmars-d mailing list