[Issue 22277] removing strongly pure function calls is an incorrect optimization

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 15 14:55:34 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22277

--- Comment #7 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to Andrei Alexandrescu from comment #5)

> > 
> > Could you explain why void and pure is a contradiction?
> 
> `void` implies "all of my work is done via side effects"

I am not sure this premise is true. A function returning 'void' may do no work
at all or do work without observable side effects. I need to think more about
this, thank you.

> and pure implies
> "there is no side effect". In D we have the relaxation of weak purity that
> makes things less clear cut. In the case of `free` in the example the
> parameter is `immutable` which makes the function strongly pure; a strongly
> pure function that returns `void` has no way to effect anything within the
> definition of the language.

Yes, I am familiar with D's concepts of purity.

--


More information about the Digitalmars-d-bugs mailing list