Uh... destructors?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Feb 23 08:48:53 PST 2011
On Wed, 23 Feb 2011 11:41:52 -0500, %u <wfunction at hotmail.com> wrote:
>> I thought @safe was orthogonal to pure? If this isn't the case,
> then yes, free must be disallowed. But then malloc must also be,
> and any construct which manages its own memory via malloc/free.
>> From what I remember, pure functions:
>> 1. cannot access shared or global non-immutable data
>> 2. cannot call non-pure functions
>> I don't remember the definition that pure functions must also be
> @safe.
>> -Steve
>
> 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.
A strong pure (one which is able to be optimized/factored) function has
one additional requirement that it's parameters and return value must all
be immutable or implicitly convertible to immutable.
To add another keyword to specify this would be wasteful.
Yes, it breaks from tradition, but D's pure functions are far from
traditional anyways.
-Steve
More information about the Digitalmars-d
mailing list