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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Problems with SPARK 2015 and XMLAda Date: Fri, 21 Aug 2015 19:44:12 -0400 Organization: A noiseless patient Spider Message-ID: <87bne0fbqr.fsf@theworld.com> References: <6952b70d-a9bc-4d0a-beb5-1cd38d6a3318@googlegroups.com> <9d3dc132-4e1a-4e9c-bcd4-82a42a73745f@googlegroups.com> <1s0gzs5wzjtq2$.1kuy63rfjsov0.dlg@40tude.net> <1j3alqfkzrx0r$.1gv7vbgpembl4$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="6f1ae94ffcb80f6d40ecfbfe47e88fbc"; logging-data="7771"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XHidSx9x1/INz+B+rluNs" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:m6ZB8Tc1nbhvedJqBkdAGi1cuCE= sha1:LELexn6GEJe0fm1OUsgee/se6/M= Xref: news.eternal-september.org comp.lang.ada:27563 Date: 2015-08-21T19:44:12-04:00 List-Id: "G.B." writes: > Design by Contractâ„¢, which wasn't defined by your or me, has > the "retry" facility as part of the "rescue"(*); ... Eiffel is a pretty good language design, but "retry" is probably my least favorite feature of that language. It's just a disguised "goto". I'm not 100% opposed to goto's in all cases, but they should normally be avoided, and this is the worst kind of goto -- a goto that jumps backward, thus forming a loop. Meyer's examples have kludgy flags to indicate "how did I get here?" As in "If I got here from the exception handler, then do the exceptional case, else do the normal case". He even has examples where there's a counter of the number of times the exception handler was entered. Yuck. And the disguised goto is worse than a goto, because there's no label saying "beware!, somebody jumps here from elsewhere!". In Ada syntax, this seems clear enough: procedure P (...) is begin Do_Something; exception when Some_Error => Do_Something_Else; end P; But Meyer prefers this: procedure P (...) is Flag : Boolean := False; begin <> if Flag then Do_Something_Else; else Do_Something; end if; exception when Some_Error => Flag := True; goto Retry; -- Illegal in Ada, for good reason! end P; Except the label is implicit in Eiffel, and the "goto Retry" is just "retry". (Oh, and the initialization to False is also implicit in Eiffel -- another bad design decision, but unrelated to "retry".) His complaint about the first version of P is that Do_Something_Else might violate contracts (because at that time, Ada didn't have any way to express contracts). But the second version of P has the same problem, for the same reason (Ada didn't have any way to express contracts). It boils down to "Ada exception handlers might have bugs". Well, yeah, but any code might have bugs. Moving the bugs from the handler to the main body of code doesn't prevent bugs. >...both, exceptions as > assertion failures and exceptions as other failures are parts of > the definitions surrounding DbC. But not in the way imagined > here. I'm sure that this imagination of "design by contract" has > somehow definitions of something quite reasonable. It would be > nice, though, if the number of naming conflicts could be small. - Bob