Re: [PATCH 0/4] Re: [PATCH 3/4] t: rev-parse-parents: avoid yoda conditions
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Sep 8, 2013, 04:13 UTC
- Message-ID
- <CAMP44s16RZ9JguL=NPcD8TE-gdG7vGEa5KLHzv4bf_VLLEhPRw@mail.gmail.com>
- In-Reply-To
- <20130908040615.GA14019@sigill.intra.peff.net>
On Sat, Sep 7, 2013 at 11:06 PM, Jeff King <peff@peff.net> wrote:
Show 11 quoted lines
> On Sat, Sep 07, 2013 at 10:11:49PM -0500, Felipe Contreras wrote: > >> > Though I prefer the current, I can certainly live and adapt to a changed >> > standard, and I do not mind doing so if there is a good reason. But I've >> > yet to see any argument beyond "it is not what I like". Which to me >> > argues for the status quo as the path of least resistance. >> >> Didn't Junio already provided reasoning? > > If the reasoning is "cmp(actual, expect) makes more sense to humans" > then I do not think it is universal.
No.
--- A(ny) sanely defined "compare A with B" function should yield the result of subtracting B from A, i.e. cmp(A,B) should be like (A-B). That is what you feed qsort() and bsearch() (it is not limited to C; you see the same in "sort { $a <=> $b }"). The definition naturally makes "cmp(A,B) < 0" like "A < B" and "cmp(A,B) > 0" like "A > B". ---
> Otherwise why would so many > existing test frameworks do it the other way?
Which many existing frameworks do it the other way?
Show 17 quoted lines
>> Here's more; human semantics: >> >> Computer, compare A with B >> cmp(A, B) >> >> Why would I write? >> >> cmp(B, A) >> >> Could you even construct an English sentence that starts with B, and then A? > > "Computer, given that we expect B, how does A differ?". Or "Computer, we > expect B; does A match it?" > > Or any number of variations. I'm sure you will say "but those seem > awkward and unlike how I think about it". But that was my point; it > seems to be a matter of preference.
Really? You think any sane human being would prefer:
Computer, given that we expect B, how does A differ?
To:
Computer, compare A with B
-- Felipe Contreras