Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart Newsgroups: comp.lang.c Subject: Re: else ladders practice Date: Fri, 8 Nov 2024 18:03:54 +0000 Organization: A noiseless patient Spider Lines: 45 Message-ID: References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> <78eabb4054783e30968ae5ffafd6b4ff2e5a5f17@i2pn2.org> <6724CFD2.4030607@grunge.pl> <2491a699388b5891a49ef960e1ad8bb689fdc2ed@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 08 Nov 2024 19:03:53 +0100 (CET) Injection-Info: dont-email.me; posting-host="33e6c63f87222477390301c1377b09f9"; logging-data="3467237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vx4hGBd8whOKKf/iNBSTM" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ow5cAdJ3Znzjsph2o2iKqr04g1Q= Content-Language: en-GB In-Reply-To: Bytes: 3055 On 03/11/2024 17:00, David Brown wrote: > On 02/11/2024 21:44, Bart wrote: >> (Note that the '|' is my example is not 'or'; it means 'then': >> >>     (  c |    a )          # these are exactly equivalent >>     if c then a fi >> >>     (  c |    a |    b )     # so are these [fixed] >>     if c then a else b fi >> >> There is no restriction on what a and b are, statements or >> expressions, unless the whole returns some value.) > > Ah, so your language has a disastrous choice of syntax here so that > sometimes "a | b" means "or", and sometimes it means "then" or > "implies", and sometimes it means "else". I missed this part of a very long post until JP commented on it. As I mentioned above, "|" here doesn't mean 'or' at all. In "( ... | ... | ... )", the first means "then" and the second "else". (It also wasn't my idea, it was taken from Algol 68.) > Why have a second syntax with > a confusing choice of operators when you have a perfectly good "if / > then / else" syntax? if/then/else suits multi-line statements. (||) suits terms that are part of a larger one-line expression. I might as well ask why C uses ?: when it has if-else, or why it needs P->m when it has (*P).m. > Or if you feel an operator adds a lot to the > language here, why not choose one that would make sense to people, such > as "=>" - the common mathematical symbol for "implies". It is not an operator, it is part of '(x | x,x,x | x)' syntax.