Skip to content

Conversation

@bigbes
Copy link
Contributor

@bigbes bigbes commented May 4, 2017

Copy link
Contributor

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments from me.

-- vim:ts=4 ss=4 sw=4 expandtab
* No whitespaces at EOL, newline at end of file (?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording is a little confusing here. An file should ends w/ one newline symbol, but shouldn't ends w/ blank line (two newline symbols).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right

* Using spaces:

- do not use a space after functions and after commas in arguments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t understand what stated here. Do not use a space btw a function name and opening circle bracket? Use a space after commas in formal arguments list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 - we shouldn't use spaces between function name and open round bracket
2 - we should use spaces after commas in the argument lists

I'll rephrase that

function name(arg1, arg2, ...)
end
- use spaces after comments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After two dashes? ‘After comment’ means for me ‘after last word of a comment’.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, after comment marker

do_something()
end
- surrounding operators:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about case when = used in a table definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar rules, but I didn't described case with alignments..

local thing = {1, 2, 3}
-- good
- Add a line break after multiline blocks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should stated expicitly that it should be one blank line btw functions / blocks — for ones who aware of PEP-0008 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll rephprase that

- ``s``/``str``/``string`` is for strings
- ``c`` is for 1-char strings
- ``f``/``func``/``cb`` are for functions
- ``status, <return_name>`` is what you get out of pcall
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m using ok in place where status suggested in this doc. Should we consider it’s okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's ok :)

* <func>'<name>' (strongly avoid require'..')
* ``function object:method() end`` (use ``functon object.method(self) end`` instead)
* use comma separator in tables, instead ``;`` or anyone else
* put comma at the end of line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid putting comma at the end of line? Why it’s bad? Can you give an example?

Copy link
Contributor Author

@bigbes bigbes May 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean semicolon here, thanks. Semicolon may be used as 'visual separator' in Lua


* <func>'<name>' (strongly avoid require'..')
* ``function object:method() end`` (use ``functon object.method(self) end`` instead)
* use comma separator in tables, instead ``;`` or anyone else
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that we must use , separator instead of ; or anything else

Copy link
Contributor

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback on the new changes.


- do not use a space after functions and after commas in arguments:
- one shouldn't use spaces between function name and opening round bracket,
but arguments must be splitted with one whitespace charachter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

charachter → character

- surround top-level function and class definitions with two blank lines.

Extra blank lines may be used (sparingly) to separate groups of related
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top level functions? So, extra line is third one? I don’t sure it’s good.
Local function? So, it’s covered by sentence about indicating logical sections on line 255.

something = 'even better'
}
- surround top-level function and class definitions with two blank lines.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s suggested by only one of three code styles you linked above. Personally I don’t like Python’s approach with two lines btw each top-level function/block. Moreover, in Lua we have ends after each function (on it’s own line), so two lines seems even more useless then in a Python code. Anyway, it’s point where third opinion would be helpful.

Maybe I confused you in our voice talk, sorry.

@rtsisyk rtsisyk requested review from Sulverus, dedok, knazarov and rtsisyk May 5, 2017 09:31
@knazarov
Copy link

knazarov commented May 5, 2017

👍
I like most of the text. Though, I don't think that 'debugging' section belongs to coding guidelines.

@rtsisyk
Copy link
Contributor

rtsisyk commented May 18, 2017

I have question about Commeting section:

Public function comments (??): + +.. code-block:: lua + + --- Copy any table (shallow and deep version) + -- * deepcopy: copies all levels + -- * shallowcopy: copies only first level + -- Supports __copy metamethod for copying custom tables with metatables + -- @function gsplit + -- @table inp original table + -- @shallow[opt] sep flag for shallow copy + -- @returns table (copy) 

Why convention is different from Doxygen? Is there any tool to generate documentation using this comments?

Copy link
Contributor

@rtsisyk rtsisyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have concerns about "Commenting" sections.

@lenkis lenkis merged commit f9a6e26 into 1.7 May 23, 2017
@lenkis lenkis deleted the lua-codestyle branch August 2, 2017 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants