From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id CDFE33853806 for ; Wed, 12 May 2021 22:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CDFE33853806 Received: by mail-wm1-x329.google.com with SMTP id o6-20020a05600c4fc6b029015ec06d5269so3792764wmq.0 for ; Wed, 12 May 2021 15:32:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9y2hInGxzegT4svP4CDRVqYYVpPndff7NkVXSp9EOhc=; b=gkbe/OwxKh6R8ybJ8R5EmImF/ArcADsJI5Urks8t74g8ChmlpiCt8n72hINU0HJcTz Seh3+c0/uhlRDLOOlvnM39flUfKc444FYOilPXCIc4/ZaruyHKeXRKGL470NKurqC1OM Wc78eqebW+sJEu9D8ekXOyiMLP1dWotmbMc+hs0GkXtvvqFpJ+qQiuPzIbJR6a8F3Emo 5H0tCmVAE1y06p3VWmnbjocQVD0tHwqc8qFt9ei8FboIRQXiVn7u71eHmHYy0LenzyDo r0iTPEX9yT10d05NgH/ixJ8ui4l243upWvQ+2QF21dhuUhtvI5lCNDg+MfrkrfAupCiS k+4w== X-Gm-Message-State: AOAM530IkLutUoXmB3pXjyyiBQmz9q6ElfXcBd3L50mehfroinOOYeDd Jvvvmnv6rcEwtmzG3HwmgaM0pHV9pl3j4A== X-Google-Smtp-Source: ABdhPJw+M8ZfzieJYT6GLANohYCkHhYXvtcdf0VW73RBztLRJ+5rROzgx6ZahSx+csDEtyfi3F/z7w== X-Received: by 2002:a05:600c:28b:: with SMTP id 11mr719529wmk.27.1620858733011; Wed, 12 May 2021 15:32:13 -0700 (PDT) Received: from [192.168.0.160] ([170.253.36.171]) by smtp.gmail.com with ESMTPSA id y17sm1115876wrw.90.2021.05.12.15.32.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 May 2021 15:32:12 -0700 (PDT) Subject: Re: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN() To: Paul Eggert , mtk.manpages@gmail.com Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org References: <20210512204311.19399-1-alx.manpages@gmail.com> From: "Alejandro Colomar (man-pages)" Message-ID: Date: Thu, 13 May 2021 00:32:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 22:32:15 -0000 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 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/