alwaysAssert() [was: Against enforce()]

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 17 18:23:51 PDT 2011


On 3/17/11 7:31 PM, Walter Bright wrote:
> 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.

These are all very good points and insights. We should keep them in mind.

Andrei


More information about the Digitalmars-d mailing list