public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>, mtk.manpages@gmail.com
Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: Re: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN()
Date: Thu, 13 May 2021 00:32:11 +0200	[thread overview]
Message-ID: <b09b67a5-2006-62b7-13fc-1930b34e848b@gmail.com> (raw)
In-Reply-To: <ca33b912-2273-b1d0-57b8-b94a19822bfd@cs.ucla.edu>

Hello Paul,

On 5/12/21 11:17 PM, Paul Eggert wrote:
> On 5/12/21 1:43 PM, Alejandro Colomar via Libc-alpha wrote:
> 
>> +If any of the arguments is of a floating-point type,
> 
> "any" -> "either"

Okay.  I thought that either meant XOR, but now I learnt it may also be OR.

> 
>> +these macros shouldn't be used
> 
> That's too strong. It's often OK to use MAX and MIN on floating point
> arguments.

Yup, I changed it a few minutes later.

> 
>> +The arguments may be evaluated more than once,
>> +and their types might be promoted to a common type
>> +if both arguments aren't of the same type.
> 
> This is muddy. It should state clearly that even if A and B are both
> integers, MAX (a, b) might not return their maximum. For example, on a
> typical C platform today, MAX (-1, 2147483648) returns 4294967295 and
> MIN (-1, 2147483648) returns 2147483648.

Hmm, yes, I'll add a BUGS section for this.  Usual arithmetic
conversions and why you should avoid them :)

> 
> Also, the man page shouldn't require the arguments to be evaluated at
> least once. It's possible to implement MAX so that it sometimes doesn't
> evaluate one argument, and the documentation shouldn't preclude such an
> implementation.

In which case they might not be evaluated at all?  I'm curious.
Maybe if one of the arguments is literal NAN and the implementation
raises an exception for it?

> 
> The man page should more specifically mention that although MIN and MAX
> are defined <sys/param.h> on GNU platforms, other platforms define them
> elsewhere or not at all.

Okay.

> 
>> +These macros return the value of one of their arguments,
> 
> Unfortunately they don't necessarily do that, as shown in the MAX
> example above.

Fixed.

> 
> I suggest looking at the remarks about MAX and MIN that are made here,
> and incorporating the useful parts of these remarks into the man page:
> 
> https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/minmax.h
> 

Okay.

Thank you very much!

Cheers,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

  reply	other threads:[~2021-05-12 22:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 20:43 Alejandro Colomar
2021-05-12 20:56 ` [PATCH v2] " Alejandro Colomar
2021-05-12 20:59   ` Alejandro Colomar (man-pages)
2021-05-12 21:17 ` [PATCH] " Paul Eggert
2021-05-12 22:32   ` Alejandro Colomar (man-pages) [this message]
2021-05-12 22:39     ` Paul Eggert
2021-05-12 22:51       ` [PATCH v3] MAX.3, MIN.3: New pages " Alejandro Colomar
2021-06-12  8:35         ` Ping: " Alejandro Colomar (man-pages)
2021-06-20  2:39         ` Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b09b67a5-2006-62b7-13fc-1930b34e848b@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).