Обсуждение: Fixed a typo in comment in compress_lz4.c

Поиск
Список
Период
Сортировка

Fixed a typo in comment in compress_lz4.c

От
Chao Li
Дата:
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/
Вложения

Re: Fixed a typo in comment in compress_lz4.c

От
Daniel Gustafsson
Дата:
> 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




Re: Fixed a typo in comment in compress_lz4.c

От
Chao Li
Дата:


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]. 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] https://www.postgresql.org/message-id/CAKFQuwa6jgVj18bRGE3edy2Z%3D5%3DDAUGL8efxG2KdWJg12nF0kw%40mail.gmail.com

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




Re: Fixed a typo in comment in compress_lz4.c

От
Tom Lane
Дата:
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]
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



Re: Fixed a typo in comment in compress_lz4.c

От
Michael Paquier
Дата:
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

Вложения

Re: Fixed a typo in comment in compress_lz4.c

От
Chao Li
Дата:


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/




Re: Fixed a typo in comment in compress_lz4.c

От
Tom Lane
Дата:
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”
isneeded? 

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



Re: Fixed a typo in comment in compress_lz4.c

От
Chao Li
Дата:


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/