Against enforce()
Steven Schveighoffer
schveiguy at yahoo.com
Thu Mar 17 10:17:08 PDT 2011
On Thu, 17 Mar 2011 12:09:50 -0400, bearophile <bearophileHUGS at lycos.com>
wrote:
> Steven Schveighoffer:
>
>> The only problem I see with it is the inline-killing.
>
> Please don't ignore the purity-killing :-)
I think this is not as much an easy fix. By changing one line in enforce,
every instance becomes inlinable. By making enforce also pure, it doesn't
automatically make all users of enforce pure.
I thought that lazy enforce cannot be pure, but I realize now that it can,
as long as the delegate is pure. However, I think the compiler won't
cooperate with that.
If we temporarily disallow lazy and also make enforce pure, it will
compile, but I'm worried one problem will be fixed and not the other, and
then we are stuck with not being able to get the benefits of the lazy
evaluation.
I think the easiest thing to do right now is make enforce not lazy. That
at least gets us inlining, which should be 90% of the performance problem
with near-zero effort. If it makes sense in the future, we can also make
it pure, or auto pure if that is ever supported.
-Steve
More information about the Digitalmars-d
mailing list