On Thu, 17 Mar 2011 13:30:21 -0400, Simen kjaeraas
<simen.kja...@gmail.com> wrote:
On Thu, 17 Mar 2011 18:17:08 +0100, Steven Schveighoffer
<schvei...@yahoo.com> wrote:
On Thu, 17 Mar 2011 12:09:50 -0400, bearophile
<bearophileh...@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.
As long as the delegate does not access shared/global data, it should be
able to be pure. Even delegates which modify TLS data should be able to
be pure (weak-pure, but still pure).
This should be easy to enforce when the delegate is created automatically
from an expression using a lazy call. However, we need some implicit
casting rules for pure delegates into non-pure ones.
-Steve