Recommendation: "functional" keyword

Simen kjaeraas simen.kjaras at gmail.com
Sun Jan 9 13:30:14 PST 2011


Eskapp <eatingstaples at gmail.com> wrote:

> Functional functions could not modify ANY data, including explicitly  
> allocating
> variables. Although, come to think of it, this wouldn't imply pure, as  
> they should
> still be allowed to read global data and call impure functions.

I don't think I understand this. pure functions modify no data except
for potential allocation and non-const ref parameters (which make the
function weakly pure). Immutable (strongly) pure functions seem to match
your charter except for the 'no allocation' part. However, your
acceptance of calling impure functions means this would be non-
transitive.

There have been suggestions that D add a keyword for 'no heap
allocation' (@noheap, I think), which in combination with immutable pure
would cover the no allocation part, as well as the no modification part.

Next question: What does this keyword add, that @noheap would not?

-- 
Simen


More information about the Digitalmars-d mailing list