Skip to contentSkip to conversation

CODING_STYLE: Add a section of the naming convention

PATCH In review Julien Grall 3 participants 8 messages Dec 1, 2023 – Dec 5, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CODING_STYLE: Add a section of the naming convention

From: Julien Grall <[email protected]>

Several maintainers have expressed a stronger preference to use '-' when in filename and option that contains multiple words.

So document it in CODING_STYLE.

---
 CODING_STYLE | 9 +++++++++
 1 file changed, 9 insertions(+)
CODING_STYLE +9 -0
index ced3ade5a6fb..afd09177745b 100644
@@ -144,6 +144,15 @@ separate lines and each line should begin with a leading '*'.
  * Note beginning and end markers on separate lines and leading '*'.
  */
 
+Naming convention
+-----------------
+
+When command line option or filename contain multiple words, a '-'
+should be to separate them. E.g. 'timer-works'.
+
+Note that some of the option and filename are using '_'. This is now
+deprecated.
+
 Emacs local variables
 ---------------------
 
Signature · 1 line
2.40.1
#1 lore raw
Quoted 19 lines · Julien Grall

From: Julien Grall <[email protected]>

Several maintainers have expressed a stronger preference to use '-' when in filename and option that contains multiple words.

So document it in CODING_STYLE.

---
  CODING_STYLE | 9 +++++++++
  1 file changed, 9 insertions(+)
CODING_STYLE +0 -0
index ced3ade5a6fb..afd09177745b 100644
@@ -144,6 +144,15 @@ separate lines and each line should begin with a leading '*'.
   * Note beginning and end markers on separate lines and leading '*'.

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 154

Quoted 10 lines
CODING_STYLE +8 -0
   */
 
+Naming convention
+-----------------
+
+When command line option or filename contain multiple words, a '-'
+should be to separate them. E.g. 'timer-works'.
+
+Note that some of the option and filename are using '_'. This is now
+deprecated.

Urgh, I sent the wrong draft :(. This is the wording I wanted to propose:

+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames. +E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now +deprecated.
+

Cheers,

Signature · 1 line
Julien Grall
#2 lore raw

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 154

Quoted 8 lines · Julien Grall
CODING_STYLE +8 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.

I certainly appreciate and second the intent, yet I'm afraid "Naming convention" in the doc would (to me at least) first and foremost talk about identifiers used in the various source files. If this really is to be about only file names and command line options, then I think the heading would better say so. Alternatively a clear indication would want adding that text about identifiers is supposed to be here, but is yet to be written. (The text itself, for the intended purpose, reads fine to me, fwiw.)

Jan

#3 lore raw

Hi Jan,

Quoted 16 lines · Jan Beulich

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 154

Quoted 8 lines · Julien Grall
CODING_STYLE +8 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.

I certainly appreciate and second the intent, yet I'm afraid "Naming convention"
in the doc would (to me at least) first and foremost talk about identifiers used
in the various source files. If this really is to be about only file names and
command line options, then I think the heading would better say so. Alternatively
a clear indication would want adding that text about identifiers is supposed to
be here, but is yet to be written. (The text itself, for the intended purpose, > reads fine to me, fwiw.)

Right now, I don't have any plan to document the naming convention for identifiers. In fact, I don't know if we have one...

So how about renaming the section to:

"Naming convention for files and comand line options"

Cheers,

Signature · 1 line
Julien Grall
Acked-by
#4 lore raw
Quoted 18 lines · Julien Grall
Quoted 16 lines · Jan Beulich

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 154

Quoted 8 lines · Julien Grall
CODING_STYLE +8 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.

I certainly appreciate and second the intent, yet I'm afraid "Naming convention"
in the doc would (to me at least) first and foremost talk about identifiers used
in the various source files. If this really is to be about only file names and
command line options, then I think the heading would better say so. Alternatively
a clear indication would want adding that text about identifiers is supposed to
be here, but is yet to be written. (The text itself, for the intended purpose, > reads fine to me, fwiw.)

Quoted 6 lines

Right now, I don't have any plan to document the naming convention for identifiers. In fact, I don't know if we have one...

So how about renaming the section to:

"Naming convention for files and comand line options"

That would be fine with me (with - nit - "command"). Then

Jan

#5 lore raw
In reply to Julien Grall
Quoted 35 lines · Julien Grall
Quoted 14 lines · Julien Grall

From: Julien Grall <[email protected]>
Several maintainers have expressed a stronger preference to use '-' when in filename and option that contains multiple words.
So document it in CODING_STYLE.

---
 CODING_STYLE | 9 +++++++++
 1 file changed, 9 insertions(+)
CODING_STYLE +0 -0
index ced3ade5a6fb..afd09177745b 100644

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 153

Quoted 10 lines
CODING_STYLE +7 -0
@@ -144,6 +144,15 @@ separate lines and each line should begin with a leading '*'.
  * Note beginning and end markers on separate lines and leading '*'.
  */
 +Naming convention
+-----------------
+
+When command line option or filename contain multiple words, a '-'
+should be to separate them. E.g. 'timer-works'.
+
+Note that some of the option and filename are using '_'. This is now
+deprecated.

Urgh, I sent the wrong draft :(. This is the wording I wanted to propose:

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 155

Quoted 9 lines
CODING_STYLE +9 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.
+

Hi Julien,

Can we make an exception for python files that are meant to be used as module? Because modules containing ‘-‘ cannot be imported using ‘import’ keyword and needs another way to do them which is not conventional

Cheers,
Luca

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
#6 lore raw

Hi Luca,

Quoted 47 lines · Luca Fancellu
Quoted 35 lines · Julien Grall
Quoted 14 lines · Julien Grall

From: Julien Grall <[email protected]>
Several maintainers have expressed a stronger preference to use '-' when in filename and option that contains multiple words.
So document it in CODING_STYLE.

---
  CODING_STYLE | 9 +++++++++
  1 file changed, 9 insertions(+)
CODING_STYLE +0 -0
index ced3ade5a6fb..afd09177745b 100644

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 153

Quoted 10 lines
CODING_STYLE +7 -0
@@ -144,6 +144,15 @@ separate lines and each line should begin with a leading '*'.
   * Note beginning and end markers on separate lines and leading '*'.
   */
  +Naming convention
+-----------------
+
+When command line option or filename contain multiple words, a '-'
+should be to separate them. E.g. 'timer-works'.
+
+Note that some of the option and filename are using '_'. This is now
+deprecated.

Urgh, I sent the wrong draft :(. This is the wording I wanted to propose:

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 155

Quoted 9 lines
CODING_STYLE +9 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.
+

Hi Julien,

Quoted 3 lines

Can we make an exception for python files that are meant to be used as module? Because modules containing ‘-‘ cannot be imported using ‘import’ keyword and needs another way to do them which is not conventional

I am not sure this needs to be written down explicitely. At the top of the file we have:

"The Xen coding style described below is the coding style used by the Xen hypervisor itself (xen/*) as well as various associated low-level libraries (e.g. tools/libxc/*).

An exception is made for files which are imported from an external source. In these cases the prevailing coding style of the upstream source is generally used (commonly the Linux coding style).

Other parts of the code base may use other coding styles, sometimes explicitly (e.g. tools/libxl/CODING_STYLE) but often implicitly (Linux coding style is fairly common). In general you should copy the style of the surrounding code. If you are unsure please ask."

and I would not describe Python as low-level.

Cheers,

Signature · 1 line
Julien Grall
#7 lore raw
Quoted 64 lines · Julien Grall

Hi Luca,

Quoted 32 lines · Luca Fancellu
Quoted 32 lines · Julien Grall
Quoted 14 lines · Julien Grall

From: Julien Grall <[email protected]>
Several maintainers have expressed a stronger preference to use '-' when in filename and option that contains multiple words.
So document it in CODING_STYLE.

---
 CODING_STYLE | 9 +++++++++
 1 file changed, 9 insertions(+)
CODING_STYLE +0 -0
index ced3ade5a6fb..afd09177745b 100644

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 153

Quoted 10 lines
CODING_STYLE +7 -0
@@ -144,6 +144,15 @@ separate lines and each line should begin with a leading '*'.
  * Note beginning and end markers on separate lines and leading '*'.
  */
 +Naming convention
+-----------------
+
+When command line option or filename contain multiple words, a '-'
+should be to separate them. E.g. 'timer-works'.
+
+Note that some of the option and filename are using '_'. This is now
+deprecated.

Urgh, I sent the wrong draft :(. This is the wording I wanted to propose:

Quoted 14 lines

CODING_STYLE separate lines and each line should begin with a leading '*'. · line 155

Quoted 10 lines
CODING_STYLE +9 -0
+Naming convention
+-----------------
+
+'-' should be used to separate words in commandline options and filenames.
+E.g. timer-works.
+
+Note that some of the options and filenames are using '_'. This is now
+deprecated.
+

Hi Julien,
Can we make an exception for python files that are meant to be used as module? Because modules containing ‘-‘ cannot be imported using ‘import’ keyword and needs another way to do them which is not conventional

I am not sure this needs to be written down explicitely. At the top of the file we have:

"The Xen coding style described below is the coding style used by the Xen hypervisor itself (xen/*) as well as various associated low-level libraries (e.g. tools/libxc/*).

An exception is made for files which are imported from an external source. In these cases the prevailing coding style of the upstream source is generally used (commonly the Linux coding style).

Quoted 6 lines

Other parts of the code base may use other coding styles, sometimes explicitly (e.g. tools/libxl/CODING_STYLE) but often implicitly (Linux coding style is fairly common). In general you should copy the style of the surrounding code. If you are unsure please ask."

and I would not describe Python as low-level.

Ok makes sense to me! Thanks

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall