Version 2 of Define Errors Out of Existence

Updated 2022-03-14 23:37:35 by pooryorick

Define Errors Out of Existence is a strategy described by John Ousterhout in A Philosophy of Software Design.

See Also

TIP #323: Do Nothing Gracefully
Lists various procedures that do nothing rather than returning an error.

Description

Ousterhout uses unset as an example of a procedure that should have used to this strategy. Instead, it returns an error if a named variable does not exist.

Examples

dict exists
Does not return an error if the first value is not a dictionary. Instead, the answer is "no". Apparently it was decided that it is preferable to allow a script to continue under that false assumption that it is working with dictionary.
encoding convertto and encoding convertfrom
encoding convertto does not return an error if a character can not be encoded in the target encoding, and encoding convertfrom does not return an error if the source encoding contains invalid encoded data.
file delete
Does not return an error if a file to delete doesn't exist.
lindex and lrange
There is no integer that results in an error. Negative integers and integers larger than the index of the last item are all perfectly acceptable. If lindex is only given one argument, it simpley returns that value, regardless of whether it's a list
binary scan
Does not return an error when it encounters a character having a Unicode code point greater than 255. Instead, it reads only the lower byte of the, ignores higher byte. Apparently in this case it was decided that data loss is preferable to returning an error.

Page Authors

pyk