enforce()?

"Jérôme M. Berger" jeberger at free.fr
Thu Jun 17 11:52:54 PDT 2010


Simen kjaeraas wrote:
> Lutger <lutger.blijdestijn at gmail.com> wrote:
> 
>> Simen kjaeraas wrote:
>>
>> ...
>>> If it cannot send the email, it may throw an Exception. If you try and
>>> pass it a handwritten letter, it should throw an Error.
>>>
>>
>> This is the question: should I segfault on a handwritten letter even
>> if it is
>> not such an important letter and could just go on operating?
> 
> Yes. If someone is passing your email system a handwritten letter,
> something is so wrong, the program should balk and exit. It's not just
> a small mixup, it's an indication something is completely wrong.
> 
	Bad example. If someone is passing bad input to your program, it
should signal the mistake and recover. External input must *always*
be checked and wrong inputs must be recovered from gracefully.

	However, if you take (and check) the user input, then put it in a
queue, then take things from the queue for processing, and you get a
handwritten letter out of the queue, *then* it is an error and
cannot be recovered from (because this should have been checked for
before putting the letter in the queue and if this is messed up, you
don't know what else may be messed up nor how bad the situation is).
Which is what you say after:

> As Walter put it, an Error, be it an AssertError or otherwise, means
> your program has ventured into uncharted territory, and behavior from
> this point on is undefined. "Permissible undefined behavior ranges
> from ignoring the situation completely with unpredictable results, to
> having demons fly out of your nose."[1]
> 

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100617/5adadfbc/attachment.pgp>


More information about the Digitalmars-d mailing list