January 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7314

           Summary: strong purity should be inferred at call site
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2012-01-18 12:05:05 PST ---
Currently, a function is considered to be strongly pure if all its formal
parameters implicitly convert to immutable.
But a function invocation can be considered strongly pure if all actual
arguments are implicitly convertible to immutable.

The following code should compile:

const(int)[] foo(const(int)[] x)pure{return x;}
void main(){
    immutable(int)[] x;
    immutable(int)[] y = foo(x);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7314


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2012-01-18 14:49:09 PST ---
I think there are ways to further improve this idea. And I think such ideas will lead to quite useful code. I have recently written two posts about related ideas. I think this is an improvement.


But I think language complexity too should be kept into account. When a programmer writes code like this:


auto foo(...) pure { ... }
void main() {
    immutable x = foo(...);
}


She should be able to usually guess correctly if such code is correct, or if it doesn't compile. The more complex D purity becomes, the less easy is to remember all the rules and exceptions to the rule, and this increases the risk of turning  programming more into guesswork than design. This sometimes happens even if every single rule looks like an improvement.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------