Hi all,
since master requires (mostly) C99 compliant compilers anyway, I wonder
if we like to update our coding standards[1], to reflect:
-
that we require (mostly) C99 compliant compilers (instead of ANSI-C
compliant compilers) -
that mixing of declarations and statements is fine
-
that C++ style comments are now allowed, or maybe that they are still
forbidden (in the latter case the stated reasons should be updated)
We may also consider to drop the "Documentation and folding hooks"[2]
section; besides that it is already partially outdated (AIUI,
doc/genfuncsummary is superseeded by doc/docgen for a long time), I
don't think these folding markers encapsulating each individual function
are useful nowadays.
Thoughts?
[1] https://github.com/php/php-src/blob/master/CODING_STANDARDS.md
[2]
https://github.com/php/php-src/blob/master/CODING_STANDARDS.md#documentation-and-folding-hooks
--
Christoph M. Becker
On Wed, May 6, 2020 at 9:32 AM Christoph M. Becker cmbecker69@gmx.de
wrote:
Hi all,
since master requires (mostly) C99 compliant compilers anyway, I wonder
if we like to update our coding standards[1], to reflect:
that we require (mostly) C99 compliant compilers (instead of ANSI-C
compliant compilers)that mixing of declarations and statements is fine
Sounds good. This restriction going away has been a great quality of life
improvement when working on master.
- that C++ style comments are now allowed, or maybe that they are still
forbidden (in the latter case the stated reasons should be updated)
It seems like in practice the style is basically /* */ for most comments
and // for TODO comments. Not sure how that came about :) No strong opinion
on whether to keep it that way or not.
We may also consider to drop the "Documentation and folding hooks"[2]
section; besides that it is already partially outdated (AIUI,
doc/genfuncsummary is superseeded by doc/docgen for a long time), I
don't think these folding markers encapsulating each individual function
are useful nowadays.
Yes, this section should be dropped. We should also drop all existing
folding marks when someone has time to come up with the right regular
expressions for that. They're a lot of noise, regularly broken and not
actually needed by any decent tooling (including vim, no idea about emacs,
but I would be very surprised if it did not support code structure based
folding).
Regards,
Nikita
Hey:
On Wed, May 6, 2020 at 3:32 PM Christoph M. Becker cmbecker69@gmx.de
wrote:
Hi all,
since master requires (mostly) C99 compliant compilers anyway, I wonder
if we like to update our coding standards[1], to reflect:
that we require (mostly) C99 compliant compilers (instead of ANSI-C
compliant compilers)that mixing of declarations and statements is fine
IMO, mixing variables and codes are always not a good practice, strict is
always means tidy..
mixing declarations and codes sometimes brings unexpected
varaibles overriden and hard to debugging.
and, I don't think make variables declaration at top of a block is a hard
thing to do.
thanks
- that C++ style comments are now allowed, or maybe that they are still
forbidden (in the latter case the stated reasons should be updated)We may also consider to drop the "Documentation and folding hooks"[2]
section; besides that it is already partially outdated (AIUI,
doc/genfuncsummary is superseeded by doc/docgen for a long time), I
don't think these folding markers encapsulating each individual function
are useful nowadays.Thoughts?
[1] https://github.com/php/php-src/blob/master/CODING_STANDARDS.md
[2]
<
https://github.com/php/php-src/blob/master/CODING_STANDARDS.md#documentation-and-folding-hooks--
Christoph M. Becker--
--
Xinchen Hui
@Laruence
http://www.laruence.com/
Hey:
On Wed, May 6, 2020 at 3:32 PM Christoph M. Becker cmbecker69@gmx.de
wrote:Hi all,
since master requires (mostly) C99 compliant compilers anyway, I wonder
if we like to update our coding standards[1], to reflect:
that we require (mostly) C99 compliant compilers (instead of ANSI-C
compliant compilers)that mixing of declarations and statements is fine
IMO, mixing variables and codes are always not a good practice, strict is
always means tidy..mixing declarations and codes sometimes brings unexpected
varaibles overriden and hard to debugging.and, I don't think make variables declaration at top of a block is a hard
thing to do.
And for me, and maybe others who have been work with c89 years,
mixed declaration and codes are guly. .
anyway, it's just my 2 cents.
thanks
thanks
- that C++ style comments are now allowed, or maybe that they are still
forbidden (in the latter case the stated reasons should be updated)We may also consider to drop the "Documentation and folding hooks"[2]
section; besides that it is already partially outdated (AIUI,
doc/genfuncsummary is superseeded by doc/docgen for a long time), I
don't think these folding markers encapsulating each individual function
are useful nowadays.Thoughts?
[1] https://github.com/php/php-src/blob/master/CODING_STANDARDS.md
[2]
<
https://github.com/php/php-src/blob/master/CODING_STANDARDS.md#documentation-and-folding-hooks--
Christoph M. Becker--
--
Xinchen Hui
@Laruence
http://www.laruence.com/
--
Xinchen Hui
@Laruence
http://www.laruence.com/
mixing declarations and codes sometimes brings unexpected
varaibles overriden and hard to debugging.thanks
--
Xinchen Hui
@Laruence
http://www.laruence.com/
In a perfect world we would be able to enable the -Wshadow GCC
compiler warning which would shout when such bugs could pop out,
however variable shadowing is pretty common in the engine, and
unless someone knows a way to "baseline" the current warnings such
that only new/refactored code warns it seems like a long shot to get
to a state where we can do that.
Another related concern may be that a variable is not yet initialized,
which can be flagged using -W-jump-misses-init, however due to a
couple of limitations enabling it is not feasible without some small
compromises, see https://github.com/php/php-src/pull/5389
Best regards
George P. Banyard
mixing declarations and codes sometimes brings unexpected
varaibles overriden and hard to debugging.In a perfect world we would be able to enable the -Wshadow GCC
compiler warning which would shout when such bugs could pop out,
however variable shadowing is pretty common in the engine, and
unless someone knows a way to "baseline" the current warnings such
that only new/refactored code warns it seems like a long shot to get
to a state where we can do that.
Isn't variable shadowing only an issue with nested blocks?
--
Christoph M. Becker
IMO, mixing variables and codes are always not a good practice
I think it depends. For example, modern languages recommend to declare i inside the for loop block instead of in the function block.
-----Original Message-----
From: Xinchen Hui laruence@php.net
Sent: Wednesday, May 6, 2020 6:20 PM
To: Christoph M. Becker cmbecker69@gmx.de
Cc: PHP internals internals@lists.php.net
Subject: Re: [PHP-DEV] Update coding standards wrt. C99?
Hey:
On Wed, May 6, 2020 at 3:32 PM Christoph M. Becker cmbecker69@gmx.de
wrote:
Hi all,
since master requires (mostly) C99 compliant compilers anyway, I
wonder if we like to update our coding standards[1], to reflect:
that we require (mostly) C99 compliant compilers (instead of ANSI-C
compliant compilers)that mixing of declarations and statements is fine
IMO, mixing variables and codes are always not a good practice, strict is always means tidy..
mixing declarations and codes sometimes brings unexpected varaibles overriden and hard to debugging.
and, I don't think make variables declaration at top of a block is a hard thing to do.
thanks
- that C++ style comments are now allowed, or maybe that they are
still forbidden (in the latter case the stated reasons should be
updated)We may also consider to drop the "Documentation and folding hooks"[2]
section; besides that it is already partially outdated (AIUI,
doc/genfuncsummary is superseeded by doc/docgen for a long time), I
don't think these folding markers encapsulating each individual
function are useful nowadays.Thoughts?
[1] https://github.com/php/php-src/blob/master/CODING_STANDARDS.md
[2]
<
https://github.com/php/php-src/blob/master/CODING_STANDARDS.md#documen
tation-and-folding-hooks--
Christoph M. Becker--
To unsubscribe,
visit: http://www.php.net/unsub.php
--
Xinchen Hui
@Laruence
http://www.laruence.com/