Improving assert-printing in DMD
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 29 14:26:59 PDT 2015
On Tuesday, 29 September 2015 at 21:26:00 UTC, John Colvin wrote:
> On Tuesday, 29 September 2015 at 21:22:43 UTC, H. S. Teoh wrote:
>> On Tue, Sep 29, 2015 at 09:13:55PM +0000, John Colvin via
>> Digitalmars-d wrote:
>>> On Tuesday, 29 September 2015 at 21:02:42 UTC, Nordlöw wrote:
>> [...]
>>> >2. Is it possible to from within DMD generate expressions
>>> >that do
>>> >
>>> >`import std.stdio : write`
>>> >
>>> >and then calls write on the `lhs` and `rsh`...or this a
>>> >completely wrong approach to solving this problem?
>>>
>>> Someone will write something like this:
>>>
>>> assert(plainPassword == plainPassword.toLower());
>>>
>>> and plaintext passwords will end up in stderr.
>>
>> That's an instance of assert abuse, and we probably don't have
>> to be responsible for it. Such checking belongs in enforce,
>> or an explicit check with an exception throw, NOT an assert.
>>
>>
>> T
>
> Not necessarily. It could just be a defensive assert for
> something that should already have been verified/cleaned/caught
> earlier.
>
> auto pass = getPassword();
> pass.clean();
> assert(pass == pass.toLower());
> //and on we go ...
It could even be in an `in { }` block
More information about the Digitalmars-d
mailing list