Sujet : Re: TeX and Pascal [was Re: The joy of FORTRAN]
De : news0009 (at) *nospam* eager.cx (Bob Eager)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 04. Oct 2024, 11:59:07
Autres entêtes
Message-ID : <lma03qFmmqaU35@mid.individual.net>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Pan/0.145 (Duplicitous mercenary valetism; d7e168a git.gnome.org/pan2)
On Thu, 03 Oct 2024 16:34:15 -0700, Peter Flass wrote:
Louis Krupp <lkrupp@invalid.pssw.com.invalid> wrote:
On 10/1/2024 3:48 PM, Lawrence D'Oliveiro wrote:
On Tue, 1 Oct 2024 16:14:37 +0100, The Natural Philosopher wrote:
And knowing that p=(x>y?3:2);
I would have done it without the parentheses. There’s too much
parenthesis clutter around as it is.
Add some spaces, and you've got something downright readable:
p = x > y ? 3 : 2;
Maybe add parentheses around the comparison, especially if it's long or
complex, which this isn't:
p = (x > y) ? 3 : 2;
It's idiomatic C. It's everywhere. Perl and Python have something
similar. So does Unisys ALGOL, not that anyone cares:
P := IF X > Y THEN 3 ELSE 2;
If you want to see gratuitous cleverness for the sake of cleverness,
there's this:
p = (x > y) + 2;
Please don't do that. Would you write:
P := REAL((X > Y) AND TRUE) + 2;
if you were doing this in ALGOL?
I didn't think so.
Louis
I like the Unisys version. At the cost of a couple of characters it’s
readable. The C version is not straightforward for those of us for whom
C is a second or third language.
The C version, of course, was merely a syntactic change from the BCPL
version (on which, via B, it was based):
p := (x > y) -> 3, 2
(parentheses optional)
-- Using UNIX since v6 (1975)...Use the BIG mirror service in the UK: http://www.mirrorservice.org