Closed apjanke closed 5 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.
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 end
s 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.
This is a multi-commit WIP work stream, and will be rebased and squashed before merging.
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.
"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.
foo(x, y, ... \n
function call that's continued on the next line.properties
, methods
, and classdef
blocks?[x,y,z] = ...
multi-argout LHS?Did some more style changes on the WIP/preallocation-ctor-form
branch. Think I got all the big ones now, except:
##
instead of #
."..."
unless there's a specific reason for '...'
.I'm a little tired; don't think I'll get to those soon.
I'm going to postpone doing the ##
block comments and "..."
double-quoted string literals until later. Closing as Fixed.
Let's convert Tablicious fully over to Octave's conventional code style.
endif
/endfor
/endfunction
/endxxx
instead of plainend
.!
instead of~
for negation.()
aroundif
,while
, andswitch
predicates.#
for comments (#
for inline comments,##
for block comments).end_try_catch
, just bc that looks gross to me.Open questions:
[a,b,c] = ...
assignments have spaces after commas like[a, b, c] = ...
?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
.editorconfig
with supporting settings, including trailing whitespace stripping.References