Re: [PATCH v2 3/6] sha1_name: avoid Yoda conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felipe Contreras <felipe.contreras@xxxxxxxxx> writes:

> Yoda speaks in reverse "Stopped they must be; on this all depends".
> "if (0 < len)" says "if zero is less than len", which is in reverse,
> as reverse as "if 1.50 is taller than you". It's all reversed: "if you
> are taller than 1.50", "if len is greater than zero", "They must be
> stopped; all depends on this".
>
> I don't understand what is not clear.

I never said anything is "not clear", did I [*1*]?

I've retitled it to "compare variable with constant, not constant
with variable" to make it easier to understand to those who did not
know the jargon (like me ;-).

By the way, after web-searching "Yoda condition", all mentions of
"Yoda condition" I found were of the

	if (constant == variable)

form, and people's justification why this form is bad, which I
happen to agree with [*2*].


[Footnote]

*1* "zero is less than len" and "len is more than zero" are saying
exactly the same thing, even though people may find it harder to
read.  While "blue is the sky" and "the sky is blue" are not saying
the same thing in the first place, and that is why I said it is not
a good analogy.


*2* I do not write equality comparison in the "constant == variable"
order myself.  For people reading from sidelines, the previous
thread on this topic is this:

    http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=3907

which explains why these were written as "if (smaller < larger)".
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]