c2lang / c2c_native

C2 Compiler - written in C2
Apache License 2.0
24 stars 5 forks source link

Add project documentation: code guideline #8

Open SchokiCoder opened 1 year ago

SchokiCoder commented 1 year ago

Add brief file like "c2c_native/docs/code_guideline.md" that explains indendations, var names std, func names std etc?

(Plus add a "please read the code guideline when contributing" to README?)

Edit: My wish for that stems from some inconsistencies that i have noticed in the indentation and variables names. Some indents use actual tabs, most don't. Some var names have snake_case others are strictly camelCase.

Examples from https://github.com/c2lang/c2c_native/blob/491a31c8e0d4c687c776bdce8cfcc11cd2d864d4/compiler/main.c2:

303:fn void plugins_start_target(void* arg, plugin_info.Info* info) {
            ^
        snake_case function

331:    console.setTiming(opts.print_timing);
                ^                         ^
        camelCase function        |
                                  snake_case variable

342:    string_pool.Pool* auxPool = string_pool.create(32*1024, 64);
                          ^
              camelCase variable

I would like to propose the following markdown document as code guideline. It doesn't reflect my personal preferences (Linux style) but what i have noticed to be the most used in the already existing codebase, except for one thing: having multiple statements in one line be allowed. I think it's just too easy to obfuscate something with that. I also didn't sit down to count how often of a way to do something actually occurs, so this may be biased by the files i read at that time.

https://github.com/SchokiCoder/c2c/blob/cdf4f6d993ca447c37b507a545275f98365e938c/docs/codestyle_guideline.md