[Issue 6074] Assert expressions shouldn't have side effects
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 29 15:13:51 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6074
Jonathan M Davis <jmdavisProg at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg at gmx.com
--- Comment #7 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-05-29 15:09:28 PDT ---
Requiring purity in asserts would be completely unacceptable in unit tests. You
would have to constantly save the results of expressions and then tests them
rather than testing them directly. You could end up doubly the length of a
typical unit tests. In some cases, it would likely even be highly annoying in
normal assertions in normal code. It's _far_ too easy for a function to not be
able to be pure for requiring purity in assertions to be practical. Even
if/when we had/have conditional purity, there's still plenty of stuff which
doesn't really have side effects which can't be pure due to making a system
call or doing something else which just can't quite be pure in spite of the
lack of side effects. The documentation on the site should be fixed to so that
it doesn't claim that it's illegal to have an expression with a side effect in
an assertion rather than "fixing" assertions so that they can't have side
effects. Warning the programmer about the risk of doing so is wise, but making
it so that they can't is not.
--
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