Front page | perl.perl6.language |
Postings from September 2005
From: Yuval Kogman
September 29, 2005 02:39
Message ID: 20050929093857.GE29485@woobling.org
I'd like to ammend, and perhaps formalize with some definitions from
my dictionary, which ships with OSX:
error - a mistake... the state or condition of being wrong in
conduct or judgement... technical - a measure of the estimated
difference between the observed or calculated value of a
quantity and it's true value.
As i see it:
when something you wanted to happen turned out different than
you programmed it to:
my $handle = open "file";
# we assume $handle exists
print =<$handle>; # but what if there was an error?
exception - a person or thing that is excluded from a general
statement or does not follow a rule
To lessen the mental load on a programmer, instead of having the
programmer write a tree of all the conditions that could happen, the
programmer can write only the condition in which the program is
Any *error* (synch problems between the code and reality) causes an
*exception* in this linearization. The control flow is an exception
to the norm, because there was an exception in the reality the
program was tailored to deal with.
The reason we handle exceptions is that sometimes we want the tree
approach, because we have well defined behavior for certain paths.
Exceptions let us separate code from "normal" code and code which is
*exceptional*, and the reason it is exceptional is usually an error.
event - a thing that happens, especially one of importance
Every error is an event. Exceptions are one way to deal with events
we were not prepared for. But events can also be waited for (select
waits for events on many file handles at a time).
Every *error* is an *event*, but an *exception* is how you deal with
events. The events that cause exceptions by default in perl will be:
errors, when 'use fatal' is in effect
warnings, but to another handler
next, redo, last, return - all control flow events that are
exceptions to the single point of entry, single point of exit
school of thought.
I intentionally did not use the computer related definitions from
e.g. wikipedia, because they are more subject to cultural inertia,
and we are trying to discover the roots of these borrowed terms.
() Yuval Kogman <email@example.com> 0xEBD27418 perl hacker &
/\ kung foo master: /me groks YAML like the grasshopper: neeyah!!!!!!