Fixed a typo in comment in compress_lz4.c

Started by Chao Li6 months ago8 messageshackers
Jump to latest
#1Chao Li
li.evan.chao@gmail.com

Hi Hackers,

Fixed a typo: "iff" -> "if" that I found while reviewing the other patch.

Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

v1-0001-Fixed-a-typo-in-comment-in-compress_lz4.c.patchapplication/octet-stream; name=v1-0001-Fixed-a-typo-in-comment-in-compress_lz4.c.patchDownload+1-2
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Chao Li (#1)
Re: Fixed a typo in comment in compress_lz4.c

On 13 Oct 2025, at 23:25, Chao Li <li.evan.chao@gmail.com> wrote:

Fixed a typo: "iff" -> "if" that I found while reviewing the other patch.

iff is shorthand for "if and only if", so it is correct here. That being said,
it's also the cause of many typofix suggstions so it's clearly not widely known
anymore and we try to avoid it new code/comments. Maybe a case could be made
for changing all the iff's in the code to aid readability, but it would have to
be measured against the induced churn.

--
Daniel Gustafsson

#3Chao Li
li.evan.chao@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: Fixed a typo in comment in compress_lz4.c

On Oct 14, 2025, at 05:31, Daniel Gustafsson <daniel@yesql.se> wrote:

On 13 Oct 2025, at 23:25, Chao Li <li.evan.chao@gmail.com> wrote:

Fixed a typo: "iff" -> "if" that I found while reviewing the other patch.

iff is shorthand for "if and only if", so it is correct here. That being said,
it's also the cause of many typofix suggstions so it's clearly not widely known
anymore and we try to avoid it new code/comments. Maybe a case could be made
for changing all the iff's in the code to aid readability, but it would have to
be measured against the induced churn.

--
Daniel Gustafsson

Oh… I was misled by [1]/messages/by-id/CAKFQuwa6jgVj18bRGE3edy2Z=5=DAUGL8efxG2KdWJg12nF0kw@mail.gmail.com. I should have done a Google search for that by myself.

I just did a search and found 219 occurrences:

```
chaol@ChaodeMacBook-Air postgresql % grep -Rho --include='*.c' --include='*.h' ' iff' . | wc -l
219
```

Do you think it is worth replacing all in a batch?

[1]: /messages/by-id/CAKFQuwa6jgVj18bRGE3edy2Z=5=DAUGL8efxG2KdWJg12nF0kw@mail.gmail.com

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Daniel Gustafsson (#2)
Re: Fixed a typo in comment in compress_lz4.c

Daniel Gustafsson <daniel@yesql.se> writes:

On 13 Oct 2025, at 23:25, Chao Li <li.evan.chao@gmail.com> wrote:
Fixed a typo: "iff" -> "if" that I found while reviewing the other patch.

iff is shorthand for "if and only if", so it is correct here. That being said,
it's also the cause of many typofix suggstions so it's clearly not widely known
anymore and we try to avoid it new code/comments.

I disagree that it's not widely known. OneLook Dictionary Search [1]https://www.onelook.com/?w=iff
defines it correctly as "Usually means: If and only if; equivalence"
and reports finding it in 35 of their underlying dictionaries,
including all the usual suspects. (Some of the 35 know the military
term "IFF: Identification Friend or Foe" rather than what we're
after, but still that's plenty of hits.)

I wonder whether adding it to our glossary would be helpful.

regards, tom lane

[1]: https://www.onelook.com/?w=iff

#5Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#4)
Re: Fixed a typo in comment in compress_lz4.c

On Mon, Oct 13, 2025 at 06:08:43PM -0400, Tom Lane wrote:

I disagree that it's not widely known. OneLook Dictionary Search [1]
defines it correctly as "Usually means: If and only if; equivalence"
and reports finding it in 35 of their underlying dictionaries,
including all the usual suspects. (Some of the 35 know the military
term "IFF: Identification Friend or Foe" rather than what we're
after, but still that's plenty of hits.)

I wonder whether adding it to our glossary would be helpful.

I think it would, it's not the first time somebody is confused by
this abbreviation. At least we would have an official reference in
the tree to be able to point to, and this term is used even by
non-native English-speaking committers (like myself) in comments,
sometimes.

(French has a version of that: "si et seulement si" or "ssi", that
I've used and seen a lot, bit only when dealing with theory in maths
or physics.)
--
Michael

#6Chao Li
li.evan.chao@gmail.com
In reply to: Michael Paquier (#5)
Re: Fixed a typo in comment in compress_lz4.c

On Oct 14, 2025, at 07:32, Michael Paquier <michael@paquier.xyz> wrote:

On Mon, Oct 13, 2025 at 06:08:43PM -0400, Tom Lane wrote:

I disagree that it's not widely known. OneLook Dictionary Search [1]
defines it correctly as "Usually means: If and only if; equivalence"
and reports finding it in 35 of their underlying dictionaries,
including all the usual suspects. (Some of the 35 know the military
term "IFF: Identification Friend or Foe" rather than what we're
after, but still that's plenty of hits.)

I wonder whether adding it to our glossary would be helpful.

I think it would, it's not the first time somebody is confused by
this abbreviation. At least we would have an official reference in
the tree to be able to point to, and this term is used even by
non-native English-speaking committers (like myself) in comments,
sometimes.

(French has a version of that: "si et seulement si" or "ssi", that
I've used and seen a lot, bit only when dealing with theory in maths
or physics.)
--
Michael

I wonder when “if and only if” should be used.

Look at this instance. The comment says:

* LZ4 equivalent to feof() or gzeof(). Return true iff there is no
* more buffered data and the end of the input file has been reached.

It just states when the function should return true. In this case, why “if” is not good enough and “if and only if” is needed?

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chao Li (#6)
Re: Fixed a typo in comment in compress_lz4.c

Chao Li <li.evan.chao@gmail.com> writes:

Look at this instance. The comment says:

* LZ4 equivalent to feof() or gzeof(). Return true iff there is no
* more buffered data and the end of the input file has been reached.

It just states when the function should return true. In this case, why “if” is not good enough and “if and only if” is needed?

Saying "if" here wouldn't fully specify the behavior. As an example,
returning constant-true would formally satisfy such a definition.
Yeah, most people would understand what is meant, but if you want
to be precise then you must make clear that the function doesn't
return true when the condition is not satisfied.

I believe that the abbreviation "iff" arose among mathematicians,
who are much more likely to be concerned about such precision than
many of us.

regards, tom lane

#8Chao Li
li.evan.chao@gmail.com
In reply to: Tom Lane (#7)
Re: Fixed a typo in comment in compress_lz4.c

On Oct 14, 2025, at 08:12, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Chao Li <li.evan.chao@gmail.com> writes:

Look at this instance. The comment says:

* LZ4 equivalent to feof() or gzeof(). Return true iff there is no
* more buffered data and the end of the input file has been reached.

It just states when the function should return true. In this case, why “if” is not good enough and “if and only if” is needed?

Saying "if" here wouldn't fully specify the behavior. As an example,
returning constant-true would formally satisfy such a definition.
Yeah, most people would understand what is meant, but if you want
to be precise then you must make clear that the function doesn't
return true when the condition is not satisfied.

I believe that the abbreviation "iff" arose among mathematicians,
who are much more likely to be concerned about such precision than
many of us.

regards, tom lane

Okay, I see. In other words, if we were replacing “iff”, “only when” would be more precise than “if”.

I think we can leave existing “iff” there. I withdraw this patch.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/