From: Seebs on
On 2010-03-05, Keith Thompson <kst-u(a)mib.org> wrote:
> Perhaps this is a better example: "The ratio of a circle's
> circumference to its diameter is pi" vs. "pi is the ratio of a
> circle's circumference to its diameter". But even there, the second
> sentence looks more like a definition of "pi" than the first one does.

Right. They're answers to different questions. One answers "I have here a
circumference and a diameter; what is the relationship between them?" The
other answers "I have this number, what does it mean?"

Similarly, there's a reason that tax forms (famed, of course, for their
excellent language, right?) say "If your income is over $N" rather than "if
$N is less than your income". (Ignoring the precise equality case, because
that's another kind of complexity.) Likewise, it's "you must be at least 48
inches tall to go on this ride", not "48 inches must be less than your
height for you to go on this ride".

Idiomatic writing matters in both English and C.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Nick on
James Harris <james.harris.1(a)googlemail.com> writes:

> On 4 Mar, 22:44, Rick Jones <rick.jon...(a)hp.com> wrote:
>> In comp.unix.programmer Nick <3-nos...(a)temporary-address.org.uk> wrote:
>>
>> > If wrong you are, my hat I will eat.
>
> Or, more Yoda-esque: If wrong you are, eat my hat I will.

But actually, thinking about it later (sad that I am) to make the 7==a
analogy better it should be "If wrong are you".
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
From: Richard Heathfield on
[Interesting bunch of crossposts!]

Keith Thompson wrote:
> Tim Streater <timstreater(a)waitrose.com> writes:
>> On 04/03/2010 20:35, Jonathan de Boyne Pollard wrote:
>>>> And "x == 7" is much more readable than "7 == x".
>>>>
>>>> At least, for English speakers it is. I don't know; maybe there are
>>>> languages in which saying "if x is equal to y" implies that x is the
>>>> constant and y is the variable.
>>>>
>>> Nonsense. This is nothing to do with speaking English.

Correct. C and English are different languages, with different purposes
and different idioms.

>>> You only find
>>> the ordering natural in C for purely circular reasons: It's natural to
>>> (most) C programmers because that's how most C language code that they
>>> have read is written. (And it's written that way because "It's
>>> natural.") Nothing more, and nothing as a result of the English language.

Right.

>> Rubbish. You don't say "if that chicken is an animal then I'll eat
>> it", you say "If that animal is a chicken then I'll eat it".

Tim, those two sentences don't mean the same thing. We're discussing
value equality, not (as Keith nicely puts it) set membership. Closer
example: "if that chicken's name is Edwina, I'll eat it" vs "if Edwina
is that chicken's name, I'll eat it".

> By contrast, "x == 7" and
> "7 == x" have exactly the same meaning in C; the only question is
> which one more clearly expresses that meaning.

No, that's not the only question. That's *one* of the questions. Other
questions include "is there truly no semantic difference?" and "does the
gain in error detection outweigh the perceived loss in readability, if
any?" My answers would be "there is truly no semantic difference" (but
the fact of asking the question made me think for a moment to confirm
that I was right about the answer), and "there is no loss in readability
and some gain in error detection, so yes" - but obviously YMMV.

> As I've said, I agree that "x == 7" is clearer. More precisely,
> I can state authoritatively that it's clearer *to me*. If others
> state that both forms are equally clear *to them*, I have no reason
> to doubt it.

In English, there is a distinction, albeit a subtle one, between "is
Fred the man who shot my chicken?" and "is the man who shot my chicken
Fred?" It's not a semantic distinction, however; rather, it's a
distinction of tone. In C, however, I can see no distinction. The
comparison-for-equality operator takes two operands. If they have the
same value, the operator yields the value 1. Otherwise, it yields the
value 0. The fact that one of them is on the right and the other on the
left (or, if you prefer, the fact that one of them is on the left and
the other on the right) is purely a consequence of the fact that C is
(mostly) linear and static in structure.

If I could animate C source, I'd have the operands orbiting the ==
operator like little (okay, big) electrons. Position is of no
consequence. But the operands of = would be fixed, because order matters
for =.

> And someone who finds "x == 7" and "7 == x" equally clear is probably
> thinking about it more clearly than I'm able to, and possibly having
> trouble figuring out what my problem is. (I'm not entirely sure
> about that myself.)

(a) no comment either way;
(b) yes;
(c) interesting. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
From: Willem on
Richard Heathfield wrote:
) In English, there is a distinction, albeit a subtle one, between "is
) Fred the man who shot my chicken?" and "is the man who shot my chicken
) Fred?" It's not a semantic distinction, however; rather, it's a
) distinction of tone.

Disagree. The semantic difference is that the first object is the item
that we're interested in, and the second is something we wish to know of
the first.

) In C, however, I can see no distinction.

In C, I see the very same distinction as I mentioned above.
(Okay, so I'm not sure it's a semantic difference, but it is a
difference that carries over to C)


) If I could animate C source, I'd have the operands orbiting the ==
) operator like little (okay, big) electrons. Position is of no
) consequence. But the operands of = would be fixed, because order matters
) for =.

How about: x <- 2 and 2 -> x as assignment operators ?
Then they can orbit as well.

After all, the two operands can be evaluated in any order, it's just
that the operator takes two different arguments (an lvalue and a value).


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
From: Richard Heathfield on
Willem wrote:
> Richard Heathfield wrote:
> ) In English, there is a distinction, albeit a subtle one, between "is
> ) Fred the man who shot my chicken?" and "is the man who shot my chicken
> ) Fred?" It's not a semantic distinction, however; rather, it's a
> ) distinction of tone.
>
> Disagree. The semantic difference is that the first object is the item
> that we're interested in, and the second is something we wish to know of
> the first.

Not entirely convinced. In each case, we wish to know whether [Fred] and
[the man who shot my chicken] are the same person.

>
> ) In C, however, I can see no distinction.
>
> In C, I see the very same distinction as I mentioned above.
> (Okay, so I'm not sure it's a semantic difference, but it is a
> difference that carries over to C)

And I see much the same absence of distinction that I see in the English
rendition.

> ) If I could animate C source, I'd have the operands orbiting the ==
> ) operator like little (okay, big) electrons. Position is of no
> ) consequence. But the operands of = would be fixed, because order matters
> ) for =.
>
> How about: x <- 2 and 2 -> x as assignment operators ?
> Then they can orbit as well.

But then it wouldn't be C, would it?

> After all, the two operands can be evaluated in any order, it's just
> that the operator takes two different arguments (an lvalue and a value).

(Nit: operators take operands, not arguments.) The order of evaluation
is not the issue here.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within