Uh... destructors?

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 23 11:08:48 PST 2011


On Wednesday, February 23, 2011 09:17:15 %u wrote:
> >> It seems that you're using the word "pure" as a synonym for the noalias
> >> and/or restrict __declspec keywords. However, they're different words
> >> because they have
> 
> different meanings. :) If you really mean noalias, then I think we just
> just call it that and introduce the attribute @noalias? Otherwise, it's a
> misuse of the term "pure", because D doesn't seem to be really using the
> term for its correct purpose.
> 
> > Don't know what those keywords are, but pure functions in the academic
> > sense are discernible from weak-pure functions via the parameters and
> > return values.
> 
> They're Microsoft-specific keywords. From MSDN:
> "noalias means that a function call does not modify or reference visible
> global state and only modifies the memory pointed to directly by pointer
> parameters (first-level indirections).
> "If a function is annotated as noalias, the optimizer can assume that, in
> addition to the parameters themselves, only first-level indirections of
> pointer parameters are referenced or modified inside the function. The
> visible global state is the set of all data that is not defined or
> referenced outside of the compilation scope, and their address is not
> taken."
> 
> 
> This is _clearly_ what D is calling "pure", and because of the fact that
> "pure" is such a misnomer and that noalias is (almost?) clearly what we
> mean, I suggest we use the latter term instead... does this sound like a
> good idea?

No. pure is what we want. Changing it would break code and contradict TDPL 
(though the addition of weakly pure isn't in TDPL). Strongly pure functions are 
essentially what you'd expect from pure. Weakly pure functions aren't, but 
they're necessary to make pure very useful, and there's no real benefit in using 
a new keyword or attribute to mark them. pure is the word used because we're 
modeling the idea that multiple calls to the same function with the same 
parameters have the same result - which is indeed the case with strongly pure 
functions. The funny case is weakly pure, but it's _not_ optimized out, and it's 
necessary for pure to be useful. You can clearly see whether a function is 
weakly or strongly pure by looking at its signature, so I really don't think 
that it's an issue.

- Jonathan M Davis


More information about the Digitalmars-d mailing list