forcing weak purity
Artur Skawina
art.08.09 at gmail.com
Wed May 23 04:48:49 PDT 2012
On 05/23/12 05:22, Steven Schveighoffer wrote:
> it has no parameters and no return, marking it as pure makes it strong pure, and an optimizing compiler can effectively remove the call completely!
Arguably a pure function not returning a value doesn't make sense... D's definition
of "pure" makes things a bit more complicated, and the fact that it is so vaguely
defined doesn't help. Eg what does "a pure function can terminate the program" mean?
A literal interpretation forbids eliminating any calls, or even moving them in a way
that could affect control flow (by terminating early/late)...
Anyway, result-less "pure" functions obviously can have side effects, so removing
calls to them shouldn't be allowed.
On 05/23/12 05:31, Alex Rønne Petersen wrote:
> I'm in favor of what you suggested on GitHub: A @weak attribute to enforce weak purity for functions marked pure.
No. "@weak" should be for defining weak symbols, reusing it for anything else would
just cause confusion,
artur
More information about the Digitalmars-d
mailing list