apjanke / octave-tablicious

Table (relational, tabular data) implementation for GNU Octave
https://apjanke.github.io/octave-tablicious/
GNU General Public License v3.0
28 stars 11 forks source link

Convert to GNU Octave code style #116

Closed apjanke closed 5 months ago

apjanke commented 6 months ago

Let's convert Tablicious fully over to Octave's conventional code style.

Open questions:

Don't care about Matlab compatibility here, because there's not much use case for running Tablicious code under Matlab at all.

It's fine to do code-style-only commits or PRs for this. And IMHO preferable: I'd rather get this all over with at once and have the whole Tablicious code base in consistent Octave style.

But wait until pr0m1th3as is done with this PR work before modifying table.m.

TODO

References

apjanke commented 6 months ago

Open question: for multiple LHS variables in an assignment like [a,b,c] = ..., should there be spaces after those commas? I'm guessing yes, because in the array-concatenation [...] syntax it uses spaces, there's spaces after commas in function calls, and everywhere else except in x(a,b,c) or x{a,b,c} indexing calls that I can see, it uses spaces. But this isn't addressed directly in the GNU Octave style guide as far as I can tell.

apjanke commented 6 months ago

I did a rough draft bulk conversion for this on branch "WIP/swift-style". It addresses most of the items noted in the description, except for converting the generic ends for try/catch blocks; "end_try_catch" is disgusting and I can't bring myself to type that. I'll consider a PR if someone else wants to do it, though.

image

This is a multi-commit WIP work stream, and will be rebased and squashed before merging.

apjanke commented 5 months ago

I merged those style changes from the "rough draft" plus a couple others to main. That covers most of this, except for the (...) around if/while predicates, and other stuff that may be in the Octave style guide but I don't remember. I'll do a reread through the style guide before closing this.

apjanke commented 5 months ago

Octave style guide re-read notes

"It is customary to prefix the error message with the name of the function that generated it." But it doesn't mention using an actual error or warning identifier (the separate arg).

"For functions that are not present in Matlab, favor the use of underscores. For example, base64_decode, common_size, or compare_versions." I'm using camelCase instead.

Under Naming, outside "Function names" it says "Do not use mixed case (a.k.a. CamelCase) names." It doesn't mention class naming at all.

"Always use double quotes for strings and characters rather than the Matlab single quote convention." Except for strings containing double quotes or backslashes.

"Enclose the condition of an if, while, until, or switch statement in parentheses, as in C", but not for for statements, including the RHS of the for x = ....

"The negation operator is written with a space between the operator and its target, e.g., ! A." Oops! I'm not doing this.

"Comments that start with a double sharp-sign, ##, are stand-alone comments that occupy an entire line." They use this even for one-line comments; those are still considered "block comments". I'm not doing this.

Things they don't cover

apjanke commented 5 months ago

Did some more style changes on the WIP/preallocation-ctor-form branch. Think I got all the big ones now, except:

I'm a little tired; don't think I'll get to those soon.

apjanke commented 5 months ago

I'm going to postpone doing the ## block comments and "..." double-quoted string literals until later. Closing as Fixed.