pureity of closures

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Mar 27 10:44:45 PDT 2015


On Fri, Mar 27, 2015 at 05:28:54PM +0000, Dicebot via Digitalmars-d wrote:
> On Friday, 27 March 2015 at 14:29:05 UTC, Shammah Chancellor wrote:
> >On 2015-03-23 09:45:39 +0000, Dicebot said:
> >
> >>I think this was not intended and is simply a side effect of limited
> >>D call graph analysis. Relaxing that limitation makes sense to me
> >>because unused impure function can be used for compile-time
> >>reflection or returned from pure function as a result (you need to
> >>ensure it does not capture pure functions as closure context in that
> >>case)
> >
> >Pure functions returning impure functions.  *BOOM* My brain just
> >exploded.
> >
> >-Shammah
> 
> As long it is exactly the same impure function for given set of
> arguments (including the context if any) it should comply it pure
> requirements, shouldn't it?

Makes sense to me.

What I'm more concerned about is whether the current compiler
implementation may accidentally allow leakage of the pure function's
internal context, which would break purity.


T

-- 
If you want to solve a problem, you need to address its root cause, not just its symptoms. Otherwise it's like treating cancer with Tylenol...


More information about the Digitalmars-d mailing list