Lies in education [was Re: The "loop and a half"]

Chris Angelico rosuav at gmail.com
Fri Oct 13 10:30:30 EDT 2017


On Sat, Oct 14, 2017 at 12:51 AM, bartc <bc at freeuk.com> wrote:
> On 13/10/2017 14:16, Chris Angelico wrote:
>>
>> On Sat, Oct 14, 2017 at 12:00 AM, bartc <bc at freeuk.com> wrote:
>>>
>>> Even if data is actually in write-protected memory, attempts to write to
>>> it
>>> will cause a crash. On my home-made system, they just did nothing. Much
>>> more
>>> graceful.
>>
>>
>> The novice thinks his job is to stop the program from crashing. The
>> expert knows that a crash is actually far FAR better than silently
>> doing nothing.
>
>
>
> For a novice, seeing 'Segmentation fault (core dumped)' is better?

Better than silently doing nothing? YES. Absolutely it is.

> There, a friendlier, more useful error message is called for ('writing into
> read-only memory' is a good start).

Minor distinction. Yes, it might be helpful to have different error
messages for different errors, but it's a trade-off.

> But the idea of having memory which is permanently or temporarily
> write-protected is also useful: you can do what you like to it and it won't
> change, and such an attempt wouldn't necessarily be an error.
>
> For example, you're drawing a series of points or connected lines into a
> window to form a shape. But part of the shape is outside the window. So you
> fix the logic and try again. You don't want it to crash if you gave it
> coordinates (corresponding to memory beyond the window limits) outside the
> boundaries.

It's common to emulate an infinite drawable area and then optimizing
it by displaying only the part that's outside the window. That's not
the same thing as silently doing nothing if something goes wrong - for
instance, ignoring one point in the shape, and drawing a shape with
fewer points. That would, in my opinion, be utterly unacceptable. And
yes, I've seen programs that do that - it's usually called a "glitch".

> It's just a technique, like greying out certain menu options - clicking them
> will do nothing, but you won't get an error message and you don't want to
> allow them anyway, risking more serious consequences.

Even there, you often CAN get a report about the failure; clicking on
something that's disabled will cause a short beep, unless that's
disabled. Maybe you personally don't like that beep, and you'd rather
it be suppressed - but that's the end user's choice, NOT the
programmer's. "Errors should never pass silently, unless explicitly
silenced."

ChrisA



More information about the Python-list mailing list