From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news2.kpn.net!news.kpn.net!nslave.kpnqwest.net!nloc2.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Function design: make errors optional? References: <3C99320B.68B9C127@tumbleweed.com> Mail-Copies-To: never From: Erik Naggum Message-ID: <3225695040075213@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 28 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 21 Mar 2002 10:23:47 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1016706227 193.71.199.50 (Thu, 21 Mar 2002 11:23:47 MET) NNTP-Posting-Date: Thu, 21 Mar 2002 11:23:47 MET Xref: archiver1.google.com comp.lang.lisp:29737 * 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.