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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f66d11aeda114c52 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Building blocks (Was: Design By Contract) Date: 1997/10/07 Message-ID: #1/1 X-Deja-AN: 278475477 References: <34316EC3.5B62@dynamite.com.au> <199710011402.QAA02444@basement.replay.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-10-07T00:00:00+00:00 List-Id: In article , Matthew Heaney wrote: >I like to handle the exceptional case first, and return early. > >>Or perhaps even: >> >> if Is_Evil(X) then >> print error message; >> return; >> end if; >> ... -- 37 lines of code doing the normal thing > >This one gets my vote. Yeah, I often do that sort of thing, too. But I've been burned more than once by return_statements in this way: I want to add some code that gets executed just before the procedure leaves, and I add it at the end without noticing that there's a return_statement buried somewhere near the beginning (perhaps a couple of nesting-levels deep). In *that* regard, a goto is better than a return, because you can add code just after the label. - Bob