Deutsch English Français Italiano |
<87cyr6jk06.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Wed, 03 Apr 2024 12:58:49 -0700 Organization: None to speak of Lines: 53 Message-ID: <87cyr6jk06.fsf@nosuchdomain.example.com> References: <uu54la$3su5b$6@dont-email.me> <20240329084454.0000090f@gmail.com> <uu6om5$cmv8$1@dont-email.me> <20240329101248.556@kylheku.com> <uu6t9h$dq4d$1@dont-email.me> <20240329104716.777@kylheku.com> <uu8p02$uebm$1@dont-email.me> <20240330112105.553@kylheku.com> <uudrfg$2cskm$1@dont-email.me> <87r0fp8lab.fsf@tudado.org> <uuehdj$2hshe$1@dont-email.me> <87wmpg7gpg.fsf@tudado.org> <LISP-20240402085115@ram.dialup.fu-berlin.de> <LISP-20240402091729@ram.dialup.fu-berlin.de> <wrap-20240402092558@ram.dialup.fu-berlin.de> <uui7hf$3gona$1@dont-email.me> <uuj1o5$3pvnq$1@dont-email.me> <87plv6jv1i.fsf@nosuchdomain.example.com> <uuk06h$1fnl$1@dont-email.me> <87le5ujrd0.fsf@nosuchdomain.example.com> <uukav6$403m$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 03 Apr 2024 19:58:55 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a67faaad1a2f17d94ae762a9e9871bf2"; logging-data="145077"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18C4OrfozQ/baDq2xhrk8ry" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:ZEcDHO/5mKZfoRxARyxuJ/V8sFU= sha1:4xfO4EBhmeMCZljm4SSORw9NFAo= Bytes: 4058 David Brown <david.brown@hesbynett.no> writes: > On 03/04/2024 19:19, Keith Thompson wrote: >> David Brown <david.brown@hesbynett.no> writes: >>> On 03/04/2024 18:00, Keith Thompson wrote: >>>> David Brown <david.brown@hesbynett.no> writes: >> [...] >>>>> That's probably the reason almost no one uses it. That post is the >>>>> first time I have ever seen conditional expressions outside of a brief >>>>> mention in a tutorial on Python conditionals showing how to write >>>>> normal conditionals in the language. I think Python stole this one >>>>> from Perl. >>>> No, Perl's conditional expressions use the same syntax as C's. >>> >>> I am not very familiar with Perl, and don't know what are expressions >>> or statements. Perhaps I have been imagining things. I had the idea >>> that in Perl you could write "<do_this> if <condition>" as an >>> alternative to the more common imperative language ordering "if >>> <condition> then <do_this>". >> Yes, but it's not the same thing. Perl has postfix conditionals, so >> you >> can write: >> statement if condition; >> but that's a statement, not an expression, and there's no form >> equivalent to if/else. It's a specific case of "statement modifiers", >> where the keyword can be any of if, unless, while, until, for, foreach, >> or when. (The latter is for an experimental "switch" feature, disabled >> by default in recent releases.) > > OK. That's a lot more than I knew. > > However, I don't see a relevant distinction between a statement and an > expression as particularly significant here, at least in terms of code > clarity. One distinction is that, for example, you can't use statement if condition; as part of a larger expression. Also, there's no else clause. Perl's statement modifiers are an alternative syntax for conditional *statements*. In particular, `statement if condition;` is equivalent to `if (condition) { statement; }`. Their purpose is to allow some code to be written more concisely. (Note that an if statement or other compound statement requires { and }.) Perl adopted C's ?: syntax for conditional expressions with little or no change. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */