Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!columba.udac.uu.se!news.mdh.se!news.seinf.abb.se!erinews.ericsson.se!eua.ericsson.se!cnn.exu.ericsson.se!newshost.convex.com!news.duke.edu!news.mathworks.com!tank.news.pipex.net!pipex!dish.news.pipex.net!pipex!tube.news.pipex.net!pipex!lade.news.pipex.net!pipex!news.airtime.co.uk!usenet From: wysiwyg@glympton.airtime.co.uk (Adam L Rice) Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather Subject: Re: What Should An Exception Handling Do? -- Clarification of rules Date: 2 Apr 1996 08:11:44 +0100 Organization: The Rice family. Lines: 59 Message-ID: <4jqjvg$d9@glympton.airtime.co.uk> References: <4irn11$7ln@mimas.brunel.ac.uk> <4j03p4$fbt@hoho.quake.net> NNTP-Posting-Host: glympton.airtime.co.uk Xref: news.daimi.aau.dk comp.object:53689 comp.lang.eiffel:22648 comp.lang.c++:176560 comp.lang.beta:10705 comp.lang.java:31153 comp.lang.sather:12404 >The exception facility of e.g. C++ is merely a (rather ad-hoc and >opaque) way of allowing the definition of what are in effect dynamically >scoped procedure names, forcibly coupled with non-local control >transfer. So, let me see if I've understood. What you're basically saying is that instead of doing (in Java): try { sock = new Socket("wallawalla.mit.edu", 3456); } catch (IOException e) { ... // handle the exception } .... // use the socket we should do something like: if (Socket.ConnectWillWork("wallawalla.mit.edu", 3456) { sock = new Socket("wallawalla.mit.edu", 3456); ... // use the socket } else { ... // handle the exception } Hmmmm... that's a lovely code style! I think we can call this techique 'APIx2', for obvious reasons. But I'm not entirely clear, it might be you were saying we should do: sock = new Socket("wallawalla.mit.edu", 3456, new CantConnectHandler()); if (!CantConnectHandler.ConnectFailed) { ... // use the socket } // some time later Class CantConnectHandler implements IOExceptionHandler { public int ConnectFailed=false; public handle(Object context) { ... // handle the exception } } Hmmm... that too is delightful! I can't think of a good name for it, so I think 'VerboseAndSlow' will have to do, though it doesn't capture the true joy of using this programming style. I can't help but feel that it's a real pity that the Java developers weren't open-minded enough to provide alternate APIs for people who wanted to program using these coding styles. Well, I say one thing for you computer scientist types, you certainly know how to make a guy glad of what he's got! I'll never complain about having to write a try ... catch statement again! Have a nice day! ,==========================================================================. | \ /\/( |\ /\//' | Adam L Rice -|- wysiwyg@glympton.airtime.co.uk | | \/\/ / )| \/\/ / \_| | Resume: http://www.csv.warwick.ac.uk/~mauhb/cv | `=========================================================================='