[Issue 9632] New: Detect Non-Mutating Call Statements to Pure Functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 2 04:02:04 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9632

           Summary: Detect Non-Mutating Call Statements to Pure Functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: per.nordlow at gmail.com


--- Comment #0 from Per Nordlöw <per.nordlow at gmail.com> 2013-03-02 04:02:00 PST ---
I believe D has the potential to add yet another cool feature to its suite of
compilers, namely the power to disallow non-side-effect calls to pure
functions.

For example

auto s = "a";
toStringz(a);

should error just like

a == "";

currently errors in DMD as

Error: == has no effect in expression (s == "")

Such as feature would prevent the programmer from accidentally calling
non-muting algorithms when he expects it to have in-place (mutating) semantics
which has cost me a lot of debugging hours. Is such a feature on the todo list
for DMD?

Also see
http://stackoverflow.com/questions/15173942/detect-non-mutating-call-statements-to-pure-functions-in-d

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


More information about the Digitalmars-d-bugs mailing list