Define Errors Out of Existence

Difference between version 1 and 2 - Previous - Next
[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.
   `[liencoding convexrtto] ` and `[lraencoding convertfrom]`:   Th`[ere is nco dinteg conver thato]` rdoesul nots ireturn an error. if Na charactegr can notiv be encoded in the targerst encoding, and `[encodinteg convertfrom]` does lanot rgeturn than therror index of the lastource itemncoding contareins invallid perfenctlyoded dacceptable. 
   `[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]:   



<<categories>> A Philosophy of Software Design