public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: "Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>,
	linux-man <linux-man@vger.kernel.org>
Subject: Re: [PATCH 1/2] ctime.3: Use VLA notation for [as]ctime_r() buffer
Date: Thu, 21 Oct 2021 11:13:32 +0200	[thread overview]
Message-ID: <94f01ce5-fd40-492a-a338-a3dbc651322b@gmail.com> (raw)
In-Reply-To: <20c1e58b-ba2b-f9df-ab1f-f80725414cf5@gmail.com>

Just forwarding a conversation to the list

On 10/21/21 10:17 AM, Alejandro Colomar (man-pages) wrote:
> Hello Jens,
> 
> On 10/21/21 9:27 AM, Jₑₙₛ Gustedt wrote:
>> Hello Alejandro,
>>
>> On Wed, 20 Oct 2021 22:22:40 +0200, Alejandro Colomar wrote:
>>
>>> As N2417 (part of C2x) suggests.  This syntax is very informative,
>>> and also, if used by library implementers, can improve static
>>> analysis.
>>>
>>> Since it is backwards compatible with pointer syntax, we can do this.
>>
>> I understand the intent, but these `_r` interfaces finally went into
>> the standard without array notation. AFAIR one of the arguments was
>> that the headers should be usable from C++.
> 
> Hmm, I understand.  If I may digress, that C/C++ incompatibility has 
> been the only real pain in reusing my C headers in C++; so much that I 
> have separate .h and .hxx header files for the same functions. 
> Eventhough C++ with VLAs would be a bad idea, parameter VLAs are not 
> really VLAs (in the sense of the same stack problems that alloca() has), 
> but syntactic sugar for pointers.  Would it be too much to ask to get 
> C++ accept that C feature?  Has it been discussed and is there any 
> consensus that it should not be done?  Or is it worth proposing to the 
> C++ comitee?
> 
> 
>>
>> So I am not sure if it is consensus to have the documentation have a
>> different form of the interfaces than the standard(s). I don't know if
>> you'd also add the attributes that glibc uses to the `printf`
>> interfaces, for example. >
>> I am not saying that you shouldn't, in the contrary it is probably a
>> good idea to list all those semantic restrictions in the documented
>> interface for which me have syntax. I just want to make sure that
>> adding such semantic hints to the documentation is consensus and
>> sufficiently well discussed.
> 
> We recently (a few months ago) added 'noreturn' and 'restrict' to the 
> man-pages prototypes.
> 
> My opinion is that we should only add a specific syntax if it adds very 
> useful information that cannot easily be read from the rest of the 
> prototype.
> 
> noreturn and restrict are examples of that, and I think [static 26] in 
> the case of these _r functions also are.  Or also [[gnu::nonnull]], 
> which BTW, as N2417 shows implicitly by the use of [static 1], which as 
> I said in patch 2/2 is confusing, I would like to suggest for the 
> standard to take it as [[nonnull]], probably for C3X I guess.
> 
> However, some attributes are not that useful.  I think 
> [[gnu::fornat(printf, 3, 4)]] wouldn't add much valuable information to 
> snprintf that isn't already readable from the prototype.  It is an 
> attribute only useful for the compiler/static analyzer, but not very 
> much for the human (compared to the noise it adds).
> 
> What I fear when adding these things is adding too much noise to the 
> SYNOPSIS.
> 
> Ideally, the standard and the man-pages would have the same prototypes. 
>   However, since the standard is not (and cannot be) perfect, when it 
> has some limitations that it cannot overcome which we can, I'll be happy 
> to differ from it.  nonnull IMO is very useful in the SYNOPSIS, so I'd 
> like to have it (and I'd also like the standard to have it, but that's 
> likely to take a decade, if it happens at all).  Also, the man-pages 
> already use array notation in some specific cases (see pipe(2)), and 
> they are mostly targeted at C programmers, so I think we can safely 
> assume that a C++ reader will know the limitation of its language, and 
> be able to translate C to C++ easily.  If any glibc programmer has any 
> concerns regarding that, this is the moment for giving a different 
> opinion :).
> 
> Thanks for your feedback!
> 
> Alex
> 
> 


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

  parent reply	other threads:[~2021-10-21  9:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 20:22 [PATCH 1/2] ctime.3: Use VLA notation for [as]ctime_r() buffer Alejandro Colomar
2021-10-20 20:22 ` [PATCH 2/2] ctime.3, strftime.3, strptime.3, timegm.3: Add [[gnu::nonnull]] to <time.h> prototypes Alejandro Colomar
2021-10-21  8:13   ` AW: " Walter Harms
2021-10-21  9:01     ` Alejandro Colomar (man-pages)
2021-10-21 17:40       ` Paul Eggert
2021-10-21 20:54         ` Alejandro Colomar (man-pages)
     [not found] ` <20211021092746.78bc82f8@inria.fr>
2021-10-21  9:12   ` [PATCH 1/2] ctime.3: Use VLA notation for [as]ctime_r() buffer Alejandro Colomar (man-pages)
     [not found]   ` <20c1e58b-ba2b-f9df-ab1f-f80725414cf5@gmail.com>
2021-10-21  9:13     ` Alejandro Colomar (man-pages) [this message]
     [not found]     ` <5782a3ea-9774-3acb-e365-1e4d03ed3358@gmail.com>
2021-10-21  9:14       ` Alejandro Colomar (man-pages)
     [not found]       ` <20211021110311.52541d69@inria.fr>
     [not found]         ` <ec620c5e-0952-fe16-353c-0210d3bea6e8@gmail.com>
2021-10-21  9:27           ` Alejandro Colomar (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=94f01ce5-fd40-492a-a338-a3dbc651322b@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=jens.gustedt@inria.fr \
    --cc=linux-man@vger.kernel.org \
    /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