www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10889] New: Invariants are useless the way they are defined

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10889

           Summary: Invariants are useless the way they are defined
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: deadalnix gmail.com



To repeat what i posted in the newsgroup :

As they are defined now, invariant are plain useless. I find 
myself disabling them one by one in my code as soon as cases get 
outside simple trivia.

The problem is that invariant are checked at the beginning/end on 
public function calls. As a consequence, it is impossible to use 
any public method in an invariant.

For instance, just right now I did refactor a struct to use 
bitfields, in order to make it more compact. Now I have to remove 
the invariant as field access are now function calls.

Another typical situation is when you want to assert certain 
properties in a class hierarchy, where calling virtual method is 
part of the invariant check.

invariant should (and must to be useful) be inserted at callee 
point, when the callee isn't itself subject to invariant 
insertion, and around public memeber manipulation (when the 
manipulator isn't subject to invariant insertion).

Any other pattern it doomed to create infinite recursion for non 
trivial invariant checks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10889


kekeniro2 yahoo.co.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kekeniro2 yahoo.co.jp



*** Issue 9412 has been marked as a duplicate of this issue. ***

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