alwaysAssert() [was: Against enforce()]
Walter Bright
newshound2 at digitalmars.com
Thu Mar 17 17:31:43 PDT 2011
On 3/17/2011 5:02 PM, Andrei Alexandrescu wrote:
> [...]
I don't disagree with anything you wrote. But I am suggesting that one liners
should have a high utility to be justifiably included in Phobos.
---------------------------------
You mentioned wondering where we should draw the line in using asserts to check
function inputs as opposed to using enforce. I suggest that line should be when
a shared library/dll boundary is crossed. Statically linked libs should use assert.
The reason is straightforward - a shared library/dll cannot know in advance what
will be connected to it, so it should treat data coming in from an external
source as untrusted input. A statically linked library, on the other hand, is
inextricably bound to a specific caller and is debugged/tested as a whole.
This raises the spectre about what to do with Phobos if Phobos is built as a dll.
More information about the Digitalmars-d
mailing list