1

I have posted a question on Stack Overflow about a curious usage of the verb "to compare" in a paper I read:

The expression a <=> b returns an object that compares <0 if a < b, compares >0 if a > b, and compares ==0 if a and b are equal/equivalent.

Translation

The expression blah-blah returns an object that compares less than zero if blah-blah...

Does this sentence make sense in English? Is this grammatically correct? Is this some grammar variant used by programmers? Can you change the verb "to compare" in the quoted text with something else while preserving the original meaning?

  • They say it differently here: In computer science, a three-way comparison takes two values A and B belonging to a type with a total order and determines whether A < B, A = B, or A > B in a single operation, in accordance with the mathematical law of trichotomy. en.wikipedia.org/wiki/Three-way_comparison. I should think your author meant: returns an object where A<B if some x is <0, etc. But I am not sure. – Lambie Nov 26 '17 at 18:46
  • @Lambie This question is about the grammar of this particular sentence, not the meaning or context of the sentence. Besides, the author means (proposed) C++ expression a <=> b < 0 is equivalent to a < b. – Nicky C Nov 26 '17 at 18:57
2

"that compares <0 if a < b" is not a traditional use of "compare". If "compare" takes a direct object, that is the thing or things being compared, but this is using it to mean the value returned.

Outside of computer science, "the value returned" by "compare" is almost meaningless (I suppose you might say that it could return true or false; but until programming was invented, nobody would ever have thought in terms of the English verb compare "returning a value", like a mathematical function.)

So this use is definitely not standard in non-technical English.

Within the context of programming, this use makes sense, and seems a convenient expression. I don't recall I've ever seen it before: maybe it has gained some currency, or maybe this instance is a new coinage. I don't know.

  • Can you help me edit the wording of my question on Stack Overflow? They say "compares less equal" is plain English!1 – q-l-p Nov 26 '17 at 21:00
  • 1
    OK, I understand what they mean now (and have commented at that thread). They are using "compare" in an unaccusative sense, like "compares favourably" (= is compared favourably). The problem is that "<0" is not normally an adverbial that can slot in to that construction. Their meaning is that when the object is compared with zero it is found to be negative: useful jargon, but definitely jargon. – Colin Fine Nov 26 '17 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.