Against enforce()

Simen kjaeraas simen.kjaras at gmail.com
Thu Mar 17 10:30:21 PDT 2011


On Thu, 17 Mar 2011 18:17:08 +0100, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> 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.

Not currently, at least. This made me wonder. A delegate created inside a
pure function would have to be pure while in the scope of that function,
right? Seems to me that should be possible to implement.


-- 
Simen


More information about the Digitalmars-d mailing list