From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61e9062c1f23b9d5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: contracted exceptions Date: Sat, 09 Jun 2007 14:14:46 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> <19fxsxv1god43$.1pqq8vgfu2itn$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1181412887 5577 192.74.137.71 (9 Jun 2007 18:14:47 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 9 Jun 2007 18:14:47 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:dXLcplP2pT1Hkk0jv1dvUxlWdzU= Xref: g2news1.google.com comp.lang.ada:16136 Date: 2007-06-09T14:14:46-04:00 List-Id: Ray Blaak writes: > Robert A Duff writes: >> Ray Blaak writes: >> > or even worse: >> > >> > try >> > { >> > doSomething(); >> > } >> > catch (SomeError e) >> > { >> > } >> >> Well, this part of the problem can't be blamed on the language. >> This code is just plain bad practise. The solution is better >> training for programmers, not better language design > > Well, you are right in theory. The problem is that such naive programmers are > directed by the compiler to do something about the exception, and being naive > they make this mistake. Training is hard, and this particular problem is > unexpectedly pervasive. I agree that training is hard, but this particular case seems pretty obvious. One can have a coding convention, and enforce it by code reviews. The compiler could warn about the above evil. The language could define such a warning to be required. As in all cases of a warning that is sometimes wrong, you need a way to suppress the message locally. Really, if a programmer doesn't understand why the above code is bad practise, the only imaginable solution is better training -- whether or not the language has Java-like rules that might encourage such bad practise. As I said, I've seen this bad practise in Ada, too -- some programmer was getting a Constraint_Error at run time, didn't understand why, and decided to put a penny in the fusebox. - Bob