Deutsch English Français Italiano |
<87h67zrtns.fsf@doppelsaurus.mobileactivedefense.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat <rweikusat@talktalk.net> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Fri, 22 Nov 2024 18:48:55 +0000 Lines: 49 Message-ID: <87h67zrtns.fsf@doppelsaurus.mobileactivedefense.com> References: <uu54la$3su5b$6@dont-email.me> <877c8vtgx6.fsf@doppelsaurus.mobileactivedefense.com> <vhqebq$c71$1@reader2.panix.com> <87o727rwga.fsf@doppelsaurus.mobileactivedefense.com> <vhqhii$d5e$1@reader2.panix.com> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net YS8e0gRyMBEiEaWSUSJgKA2jTsJfxfYCXyVcDLZ7+KlY4Q+aE= Cancel-Lock: sha1:23pSVbbu9KcP3hkWBk7RGGWeqSU= sha1:HTufyZ15xopopEWP8hDFvBeqp7k= sha256:WHu9+MCUSSUEUP8DKBABPjCN2ErMg76Bm4gM46hZR3E= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Bytes: 2467 cross@spitfire.i.gajendra.net (Dan Cross) writes: [...] > In any event, this seems simpler than what you posted: > > #include <stddef.h> > #include <stdio.h> > #include <stdlib.h> > > int > main(int argc, char *argv[]) > { > if (argc != 2) { > fprintf(stderr, "Usage: matchd <str>\n"); > return EXIT_FAILURE; > } > > for (const char *p = argv[1]; *p != '\0'; p++) > if ('0' <= *p && *p <= '9') > return EXIT_SUCCESS; > > return EXIT_FAILURE; > } It's not only 4 lines longer but in just about every individual aspect syntactically more complicated and more messy and functionally more clumsy. This is particularly noticable in the loop for (const char *p = argv[1]; *p != '\0'; p++) if ('0' <= *p && *p <= '9') return EXIT_SUCCESS; the loop header containing a spuriously qualified variable declaration, the loop body and half of the termination condition. The other half then follows as special-case in the otherwise useless loop body. It looks like a copy of my code which each individual bit redesigned under the guiding principle of "Can we make this more complicated?", eg, char **argv declares an array of pointers (as each pointer in C points to an array) and char *argv[] accomplishes exactly the same but uses both more characters and more different kinds of characters.