www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9632] New: Detect Non-Mutating Call Statements to Pure Functions

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: per.nordlow gmail.com


--- Comment #0 from Per Nordl÷w <per.nordlow 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: -------
Mar 02 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9632


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bearophile_hugs eml.cc
         Resolution|                            |DUPLICATE


--- Comment #1 from bearophile_hugs eml.cc 2013-03-02 05:36:15 PST ---
*** This issue has been marked as a duplicate of issue 3882 ***

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