Subject: Re: Function design: make errors optional? From: Erik Naggum <firstname.lastname@example.org> Date: Thu, 21 Mar 2002 10:23:47 GMT Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Matthieu Villeneuve | I was wondering if it could be accepted as "good style" to define a | function in a way that makes the caller able to decide whether, if an | error happens during its evaluation, the function should throw an error, | or produce a default result. You might find warn and signal useful in this regard, instead of error. That way, your caller may set up a condition handler and decline to handle a particular condition, or not set up any condition handlers and effectively ignore the conditions, such that you can return a useful default value instead. | For example, an imaginary function that adds an edge between two | vertices of a graph could, depending on the value of a keyword parameter | NO-ERRORS, either throw an error if one of the vertices doesn't exist, | or silently add the missing vertices: I think a keyword argument like :if-does-not-exist with a :create or :error argument would be a good design choice here. See open. | Any thougths? Are there any commonly accepted idioms about that issue? Well, there are several. read has already been mentioned. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief.