[Issue 4974] Cannot have pure constructor due to impure invariant

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 9 04:14:47 PST 2010


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



--- Comment #4 from bearophile_hugs at eml.cc 2010-11-09 04:13:41 PST ---
(In reply to comment #3)
> I rather like the idea of the compiler
> acting like all invariants are pure so that you can have pure functions and
> still be able to use stuff like writeln() in your invariant when debugging. As
> it is, marking an invariant as pure does seem to make it possible to have pure
> functions, but it eliminates your ability to print debug statements in
> invariants.

A possible solution using the idea in bug 5125 (syntax is temporary):

pure nothrow bool isDebug() {
    debug return true;
    return false;
}

@optional_tag(ifDebug(), pure) invariant() { ...

-- 
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