LISP error handling gotcha.
> (defun resolve-host-name (addr) (handler-case (hostent-name (resolve-host-ipaddr addr)) (t () addr))) RESOLVE-HOST-NAME > (resolve-host-name "126.96.36.199") "188.8.131.52" > (resolve-host-name "184.108.40.206") "tservice.net.ru"
Exception mechanism is a great extension to the whatever language, and I think LISP has one of the best realizations (and the first one actually). I’m not very familiar with the exceptions in C++ as long as with language itself, but iirc it is not (easily) possible return back to the calling point with some value determined by the exception handler. Even in Java with its
section it is still less convenient. But I may be wrong of course :)
Above chunk of the code catches the error (all exceptions) and returns requested address itself, and when no error happend it returns resolved address.