Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.misc Subject: Re: The joy of FORTRAN Date: 3 Mar 2025 05:28:50 GMT Lines: 34 Message-ID: References: <5mqdnZuGq4lgwm_7nZ2dnZfqnPSdnZ2d@earthlink.com> <1smdnSjX3YoxgWf7nZ2dnZfqn_idnZ2d@earthlink.com> <1396870532.749421730.052473.peter_flass-yahoo.com@news.eternal-september.org> <1214951717.762291306.657281.peter_flass-yahoo.com@news.eternal-september.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net x1CIsCWrWNEbOsYVdlrHIgkNPXjI2uD8ZQYUioXzFD63Izdlnm Cancel-Lock: sha1:yciuGNgq/R5nrqn4/ZGYuRPCcfc= sha256:G2vho44w6HGeYPpGNN2m65grGmkOC/JrgjUAVwgZVSw= User-Agent: Pan/0.160 (Toresk; ) Xref: csiph.com comp.os.linux.misc:65969 On Sun, 02 Mar 2025 23:12:28 GMT, Charlie Gibbs wrote: > Another thing I do to make code compact is to omit the braces if the > body of the if or for is a single line. However, I won't do this if the > next line is up two or more levels, since I want everything to be > accounted for with braces. For instance: > > for(i = 0; i < 10; i++) { > printf("%d\n", i); > if((i % 2) == 0) /* Omitted braces */ > printf("The preceding number is even.\n"); > if((i % 3) == 0) { > printf("The preceding number is a multiple of 3.\n"); > } /* Don't go up two levels without braces! */ > } > I tend to use the braces for ifs out of self defense. I've been burned a couple of times with stuff like if (foo == bar) exit(-1); and at some later time deciding some logging would be nice. if (foo == bar) log("something went off the rails!): exit(-1); I also do things like test the return of malloc(). I know if malloc() returns NULL I probably have a snowball's chance of logging or doing anything graceful but it's worth a try.