From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [IPv6:2600:3c01:e000:146::1]) by inbox.vuxu.org (Postfix) with ESMTP id 4EA6322815 for ; Fri, 5 Apr 2024 00:53:51 +0200 (CEST) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 0096142965; Fri, 5 Apr 2024 08:53:49 +1000 (AEST) Received: from irmo.kmail.bg (unknown [IPv6:2a01:8740:ffff:ffdc::2]) by minnie.tuhs.org (Postfix) with ESMTPS id 753AA42963 for ; Fri, 5 Apr 2024 08:53:41 +1000 (AEST) Received: from straylight.ringlet.net (unknown [93.152.132.21]) by irmo.kmail.bg (Postfix) with ESMTPSA id 27BA14009C for ; Fri, 5 Apr 2024 01:53:30 +0300 (EEST) Received: from roam (uid 1000) (envelope-from roam@ringlet.net) id 194152c by straylight.ringlet.net (DragonFly Mail Agent v0.13); Fri, 05 Apr 2024 01:53:29 +0300 Date: Fri, 5 Apr 2024 01:53:29 +0300 From: Peter Pentchev To: coff@tuhs.org Message-ID: References: <1d3f129c-eafe-4fb2-9ea2-d949f3813c88@technologists.com> <516a4019-d987-4ca4-ac62-bd6b40841f93@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jyr6BgXJDlGRjwVp" Content-Disposition: inline In-Reply-To: <516a4019-d987-4ca4-ac62-bd6b40841f93@gmail.com> Message-ID-Hash: RF4Q4UPZ7RN2ITD35BBYPRU7GC3KQ7KU X-Message-ID-Hash: RF4Q4UPZ7RN2ITD35BBYPRU7GC3KQ7KU X-MailFrom: roam@ringlet.net 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 X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [COFF] Re: Of PL/I List-Id: Computer Old Farts Forum Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --jyr6BgXJDlGRjwVp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 04, 2024 at 04:37:23PM +1300, Wesley Parish wrote: > On 4/04/24 06:30, segaloco via COFF wrote: > > On Wednesday, April 3rd, 2024 at 9:18 AM, Paul Winalski wrote: > >=20 > > > In the PL/I shops I worked at it was required that all declarations b= e at the beginning of the scope block. > > > -Paul W. > > I get (friendly) flack for this from some of my coworkers, context is w= e're a C# and Java(Type)Script shop. They poke fun at how I write these la= nguages like a C programmer but I don't ever hear anyone complaining about = the readability of my code :) > >=20 > > Declarations anywhere else but the top of blocks irks me, even if the l= anguage is totally fine with it. The only exception is asm, putting all th= e data and bss at the bottom of assembly units instead. >=20 > I learn C by reading Tanenbaum and Comer's OS books, and I cannot imagine > how putting variable declarations anywhere other than the top of the > function they belong to, would make sense. Unless they are global, in whi= ch > case they go in a suitably global header file. TBH, the fact that variables can now be declared in the middle of a block is one of the things that I use most in C90 and C99. Caveat: I only use it in combination with the "const" keyword for single-assignment variables, similar to the bindings in some functional languages. The result is that even the compiler will yell at me if I try to do something funny to a variable that I have declared as "this is its value; it is really, really not supposed to change during its lifetime, but I'm storing it into a variable mainly to cache it for reuse". A side effect is that the compiler has another optimization hint. It also prevents me from using the same name for two different variables, even by accident. G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@debian.org pp@storpool.com PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 --jyr6BgXJDlGRjwVp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEELuenpRf8EkzxFcNUZR7vsCUn3xMFAmYPL2QACgkQZR7vsCUn 3xO+GhAAvyXUe//+oCkiFZ92q3nhKi3PkQ9O/Q5sXYdd4ktOB9p5REynvU1fiaCw 7ay6L6mbwJEsoxYZxF7SeLgq+72J3pxmYFm6p174MZY8HCuT7E28IIP0L3HkJVYa iTHNEuFTnIHqjrxls88kODYPDXa8m+jhqdjfvDqkQ7eWuBzgYjd4jq5svrJojDk2 d1VfUJHjoEFZTZv4GZbiHWoILjuIGY4h1gWA9ScsxfLbBS7L/8iQ71sSCRX4ABUc sx79TFk0hbk+TAwCRGkmiw6oocQupPxnq2Q8PcxPXV4bMadqmaTlTapQ+nh4RE8/ bowHnOo1EjhXrHsQcc8Essuzm+BHsIjk/WpJlBaCicHcEePbt2IjTMxxgTBtnCRg heyXB3I45R6T0N/E4+N0jCECs+NtYOGBVYJHbMRMx7bscwe4xm+vOnMM+I+iGIv3 mZavINDlok0pjWT64gqXXPgE96yljbhU0dPbKFlN7dh//EnT7Lq6Wb2OlN3Qef1p Uqvd+Pe34B9UClsz7pySSXz4cJTTN18mrgYp8gn1ExDMkhZxlAzL3hrHZb+s5IdH UJW3zcCV06vH1Ha6nDuJLJSDNrIu3NwtPsmnfoIEOplUxkScqZ8OcI6/BLL5mk1j qQ3AUuoD3T2NmTvn40LTSYWKuivjXNw5pWiOlTjygGWHj3b80hE= =nHAd -----END PGP SIGNATURE----- --jyr6BgXJDlGRjwVp--