Deutsch English Français Italiano |
<vhpp2q$15aen$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Fri, 22 Nov 2024 12:14:32 +0100 Organization: A noiseless patient Spider Lines: 38 Message-ID: <vhpp2q$15aen$1@dont-email.me> References: <uu54la$3su5b$6@dont-email.me> <87edbtz43p.fsf@tudado.org> <0d2cnVzOmbD6f4z7nZ2dnZfqnPudnZ2d@brightview.co.uk> <uusur7$2hm6p$1@dont-email.me> <vdf096$2c9hb$8@dont-email.me> <87a5fdj7f2.fsf@doppelsaurus.mobileactivedefense.com> <ve83q2$33dfe$1@dont-email.me> <vgsbrv$sko5$1@dont-email.me> <vgtslt$16754$1@dont-email.me> <86frnmmxp7.fsf@red.stonehenge.com> <vhk65t$o5i$1@dont-email.me> <vhkev7$29sc$1@dont-email.me> <vhkh94$2oi3$1@dont-email.me> <vhkvpi$5h8v$1@dont-email.me> <875xohbxre.fsf@doppelsaurus.mobileactivedefense.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 22 Nov 2024 12:14:34 +0100 (CET) Injection-Info: dont-email.me; posting-host="0bffdfc6132b7c2549c575b8240be95d"; logging-data="1223127"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184zGmswKc1ampVLAKBsmiL" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:X2S9NQAlsBbkHc/ycIgeblM2kn4= In-Reply-To: <875xohbxre.fsf@doppelsaurus.mobileactivedefense.com> X-Enigmail-Draft-Status: N1110 Bytes: 3265 On 20.11.2024 18:50, Rainer Weikusat wrote: > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: > >> Personally I think that writing bulky procedural stuff for something >> like [0-9]+ can only be much worse, and that further abbreviations >> like \d+ are the better direction to go if targeting a good interface. >> YMMV. > > Assuming that p is a pointer to the current position in a string, e is a > pointer to the end of it (ie, point just past the last byte) and - > that's important - both are pointers to unsigned quantities, the 'bulky' > C equivalent of [0-9]+ is > > while (p < e && *p - '0' < 10) ++p; > > That's not too bad. And it's really a hell lot faster than a > general-purpose automaton programmed to recognize the same pattern > (which might not matter most of the time, but sometimes, it does). Okay, I see where you're coming from (and especially in that simple case). Personally (and YMMV), even here in this simple case I think that using pointers is not better but worse - and anyway isn't [in this form] available in most languages; in other cases (and languages) such constructs get yet more clumsy, and for my not very complex example - /[0-9]+(ABC)?x*foo/ - even a "catastrophe" concerning readability, error-proneness, and maintainability. If that is what the other poster meant I'm fine with your answer; there's no need to even consider abandoning regular expressions in favor of explicitly codified parsing. Janis PS: And thanks for answering on behalf of the other poster whom I see in his followups just continuing his very personal style.