From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1046 invoked from network); 10 Mar 2023 19:05:06 -0000 Received: from minnie.tuhs.org (2600:3c01:e000:146::1) by inbox.vuxu.org with ESMTPUTF8; 10 Mar 2023 19:05:06 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 99CB041592; Sat, 11 Mar 2023 05:04:59 +1000 (AEST) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by minnie.tuhs.org (Postfix) with ESMTPS id D32C541425 for ; Sat, 11 Mar 2023 05:04:53 +1000 (AEST) Received: by mail-lf1-x12b.google.com with SMTP id n2so7928203lfb.12 for ; Fri, 10 Mar 2023 11:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678475091; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zn6TbD+zMVM1mCbhsnkPVR2Of5xzqxC4Ma9XxbUIYno=; b=PzSaRii3BUic9oommjQZkU8eUcGEH1fuX9whUXIISxzWkSRdBYX1h81WGzSPijRXWY DeRWOKD4GVrDNUAG+cDIsHVBRdcNfSbtV/JvIPDTG6ZApKY+jV4rFowabRrMY5bCM1HU 1NITeRSiTLu0bp4coU5pAk8lFpH2rtvZ6cmWDTu01E3u4uGvYeOLYn0d1Lg3hgcmyPiS EhSZPwgtLLfT2iEdYE/jDmr7ezQqhR4SFx6KukGhJWO6gxzLP7XHhjkJw1wvpB38BYsA xAdVsXqDqKxZ8tfn2c5NDlG6rlh18lDpaqXUXw80dCnnyxSP3OCjP/WojSwMCpkiZcXe iglg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678475091; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zn6TbD+zMVM1mCbhsnkPVR2Of5xzqxC4Ma9XxbUIYno=; b=3l60+Um7O/zyjp5obvsnCA5OsGgE5nUyhQ7OMVhGR2C7szcu5ZPxrc1y3gHVxeEYwh c48s4IFWDmkseqsQysJNJCPwAZucTSDW8YmgS65+J/bvZGlvCpsjrOiQ42+5gaWd5XtN E4R9u5Mmcc7r3+IeVzbL9qGhR6dszN+73zzM6sW2cqFJFf+RERQNdoP9fYXTTMCQX/8m hvMbht4/LqBHusJJ/0y1eLI+Zd42hpJIBOI04UDQRSHogZhWqbx/izk7YeuxjpvdfWlL TaQyrEW6E5lcleWkrwtZT3Moi7oyFr8LTpE8QxVh7yE2GpZbNBTGhfhQ8PN02WHTGHIY rkUQ== X-Gm-Message-State: AO0yUKWMnMxAhFr2Md9/+Po2bd6GCUcnRlmO4NWiUflDLXnh/ua2Ptev 4oawz3eVmTmlA1OCAquzaLthtM60K1BZaPSBmbZjbDLV X-Google-Smtp-Source: AK7set+mdeCIwOiV9U2A6xZzfpQhPBA58nJcInXaNKc+4qd7J31C0ErGQ4ohdnEUplx/gYhNm+bCdnRDsTbbxlRgwzA= X-Received: by 2002:a05:6512:20d:b0:4d5:ca43:7047 with SMTP id a13-20020a056512020d00b004d5ca437047mr8228292lfo.10.1678475091474; Fri, 10 Mar 2023 11:04:51 -0800 (PST) MIME-Version: 1.0 References: <20230310153702.AFF3418C080@mercury.lcs.mit.edu> In-Reply-To: From: Dan Cross Date: Fri, 10 Mar 2023 14:04:15 -0500 Message-ID: To: Ron Natalie Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XNTSFRHQMKRSVCVY5O7T4XNBJ54JNB67 X-Message-ID-Hash: XNTSFRHQMKRSVCVY5O7T4XNBJ54JNB67 X-MailFrom: crossd@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Noel Chiappa , tuhs@tuhs.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: I can't drive 55: "GOTO considered harmful" 55th anniversary List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, Mar 10, 2023 at 1:55=E2=80=AFPM Ron Natalie wr= ote: > That=E2=80=99s my point. Both break structure. > > Just hinding the break with some construct that isn=E2=80=99t =E2=80=9Cgo= to=E2=80=9D doesn=E2=80=99t > make it acceptable. The alternative is often worse, though. I'd take a well-aimed goto or a nested break over a bunch of conditionals in the bodies of loops any day, both in terms of readability and performance. That said, I'm not a huge fan of the `goto fail;` pattern. Apple had a pretty major bug with that, and I find that many, many times it can be replaced with a restructuring of the code. For example, perhaps do your allocation, call a function and capture the return value (passing the allocated resources as arguments), and then de-allocate and return the cached return value. Let the compiler optimize it. As an experiment, I rewrote the Apple bug code (which was open source) to do that and it was cleaner and simpler than the original. Someone I showed it to said, "but what, are you going to do that for _every_ function that can fail?" Well no, but generally you don't have to; we fixate too much on the general problem and ignore the specifics. - Dan C.