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

2011-07-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||yebbl...@gmail.com
 Resolution||FIXED


--- Comment #8 from yebblies yebbl...@gmail.com 2011-07-10 17:31:56 EST ---
Now that we have printing from pure functions inside debug conditions, I think
this is all solved.

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


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

2010-11-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974



--- Comment #4 from bearophile_h...@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: ---


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

2010-11-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974



--- Comment #5 from Don clugd...@yahoo.com.au 2010-11-09 04:33:50 PST ---
(In reply to comment #3)
 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.

I don't think that problem is unique to invariants.  It's the same issue as
logging in pure functions, and in CTFE functions.

You should be able to do printf-style debugging in ANY pure function.

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


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

2010-11-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974



--- Comment #6 from bearophile_h...@eml.cc 2010-11-09 04:40:16 PST ---
(In reply to comment #5)

 You should be able to do printf-style debugging in ANY pure function.

Do you mean something like this?

pure void foo() {
debug { printf(foo); }
}


And even giving the compiler an explicit debug{} tag that is tricky. In general
writing is a side effect. So if your programs output is the text it produces,
its output may change according to how much the compiler optimizes away pure
function calls.

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


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

2010-11-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au


--- Comment #2 from Don clugd...@yahoo.com.au 2010-11-08 19:14:18 PST ---
In DMD2.050, 'pure invariant()' compiles, which was your solution 1. Not sure
if that's enough to mark the bug as fixed.

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


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

2010-11-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4974



--- Comment #3 from Jonathan M Davis jmdavisp...@gmx.com 2010-11-08 22:36:47 
PST ---
Well, marking an invariant as pure does seem to actually make it pure which is
a definite improvement, though honestly, 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.

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