wtsnjp / llmk

Light LaTeX Make
https://ctan.org/pkg/llmk
MIT License
110 stars 5 forks source link

Code reorder in separate modules and other (many) changes #3

Closed robitex closed 5 years ago

robitex commented 5 years ago

Hi, this is a huge pull request, I'm sorry, introducing modules in llmk. The main criteria is avoid global variables and insert a strong separation of different functionality via modules, such as TOML, GetOp or Debug (see the following list), even if we have only one script file. This isn't the final code (it's not yet completely modular), because the code still lacks of a complete and stable reformulation.

Every module comes with private and public functions (and this is under further investigation to how better isolate the code). At this stage, the convention requires an underscore character in front of the name of private functions, such as _parse_string(). Instead, public functions are references as fields of Lua table that represents the module.

This is the module list that I've thought so far: GetOpt : parsing option and argument from command line Debug : printing useful information of the processes TOML : parsing textual TOML data Cmd : building and running terminal commands (not yet ready) Other : any other necessary module

I also introduced a format for the parameters returning from a function similar to the syntax of other language such as Go and in a certain way, in Rust: the pair value, error parameters alternatively nil. So the error management becomes an external responsability (related to the caller). In other words, modules are indipendent also for error handling.

Thank you very much. R.

wtsnjp commented 5 years ago

First, sorry for my late response.

I agreed that now it is the right time to introduce modules into this project. However, I have my preferred way of modularising a Lua product. As an author of Texdoc, it is much more desirable for me to make Texdoc and llmk have a similar architecture. Thus, I introduced modules in my way (334f408).

Although I cannot merge this PR as a whole, by quickly reviewing your code I saw lots of techniques to learn. I'm sure some of those will improve the latest code as well. If you still have a passion to contribute to this project, I'll appreciate if you could send another PR to the current HEAD of this repository. Sorry for the inconvenience.

robitex commented 5 years ago

Thanks a lot. I'm happy to hear those news about modules in llmk. Now, I'm involved in other projects and I've no time for anything else. I'm sorry. May be in the next future I will make other PRs or contributions. As a general rule I prefer do not use global variables. IMHO this is much important. R.

wtsnjp commented 5 years ago

Just for your information, all global variables are already eliminated 😉