[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Should we rename and untypedef nano's structs?

From: Devin Hussey
Subject: Re: [Nano-devel] Should we rename and untypedef nano's structs?
Date: Sun, 19 Aug 2018 18:46:51 -0400

There are a few ways to name your functions, variables, etc.

There is snake case, used by Rust, nano, glib, Python, and the STL. It
uses all lowercase separated by underscores.
size_t std::string::find_first_of();

Then there is title case, used by Windows API, Apple's C API, and many
C projects. It uses all words in title case without spaces:
long WINAPI BroadcastSystemMessage()

Then, there is camel case, used mainly by Apple, Java and Qt:
[[NSString alloc] initWithBytes];

Lastly, there is the abbreviated mess that C's standard library uses:
strpbrk (string pattern break?)
fopen (file open)
getdelim (get delimiter)
gets (stop programming now)

Camel case and title case are almost always used together to separate
object names and function names, as done in Apple, Qt and Java.
bool QObject::blockSignals();

While snake case can technically use capitals, it is not common and
looks weird. In this case, it is usually used for "namespacing" in C.

Typedefing struct away works best in camel case projects, because if
you use title case, it stands out from camel case and the lowercase

FileStruct *createFileStruct();
FileStruct *myFileStruct = createFileStruct();
void FileStruct_doSomething(FileStruct *fs, int x);

However, with camel case, sometimes things just blend in.

auto x = std::chrono::high_resolution_clock::now();
jack_client_t * jack_client_open (const char *client_name,
jack_options_t options, jack_status_t *status, ...);

That is when I think the struct keyword helps.

> From: Benno Schulenberg <address@hidden>
> To: address@hidden
> Cc:
> Bcc:
> Date: Sun, 19 Aug 2018 20:57:17 +0200
> Subject: Re: [Nano-devel] Should we rename and untypedef nano's structs?
> Op 19-08-18 om 16:30 schreef Devin Hussey:
>> nano's struct types are weird, and the typedefs are inconsistent with
>> the snake case and themselves. Some of them are extremely confusing.
> What's "snake case"?
> But true, nano's structs are poorly named and confusing.
>> filestruct is a useless typedef that saves a single space, and doesn't
>> represent a file itself, rather a line/node.
>> openfilestruct is the actual filestruct.
>> sc is shortcut, but it doesn't look like it.
> All three true.
>> subnfunc... what the hell does subn mean?
> I have no idea.
>> So my ideas:
>> filestruct -> struct node, struct line
>> openfilestruct -> struct file, struct open_file, struct buffer
>> sc -> struct kbd_shortcut, struct shortcut
>> [...]
> What they should be renamed to, I don't know.  And we won't
> rename them all at once.  One at a time.
> Benno

reply via email to

[Prev in Thread] Current Thread [Next in Thread]