enforce()?
dsimcha
dsimcha at yahoo.com
Wed Jun 16 08:44:16 PDT 2010
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> Everybody talks about them but I've seen none.
> The fact that the coder doesn't need to think hard to use enforce()
> effectively is a plus, not a minus. An overdesigned enforce that adds
> extra burden to its user would have been a mistake.
> Andrei
IMHO the presence of a simple method of handling errors, even if it's far from
perfect, is a good thing. If you have to think about a whole exception hierarchy
every time you hit a possible error condition in your code, you tend to put this
tedious task off until forever, leading to programs that fail for unknown reasons
because some error condition was never reported. Well-designed exception
hierarchies are nice, but forcing their use all the time would be making the
perfect the enemy of the good.
Furthermore, I love enforce() because sometimes I want just some subset of
assertions checked in release mode, usually whichever ones can be checked at
negligible performance cost. I tend to use it a lot as an
assert-even-in-release-mode function.
More information about the Digitalmars-d
mailing list