-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] - Style Guide, Best Practices, etc. #532
Comments
Yeah it's a good idea, having some sort of conventions on the docs somewhere could be a good start. Later down the road we could potentially start creating a linter that helps enforce these rules as well |
@Jason2605 Happy for any and all feedback on the proposal below. Not married to any of the opionions. IntroductionThese guidelines attempt to provide a framework for code styling and formatting with the end goal of having all Dictu code similar enough for maximal familiarity and readability. FormattingFavor 4 spaces over tabs. CommentaryDictu supports single and multiline comments in the form of For example: // class User provides ...
class User {
private password;
// User class initializer. Creates a new user value, sets the given name fields,
// and generates a new password.
init(var firstName, var lastName) {
// generate a new password.
this.password = generatePassword();
}
} Module NamesDepending on how a module is imported, either the module name becomes the accessor or the item imported is accessed directly. Modules should have short names and be simple nouns describing the contents. For example: import System; ImportsImports should be grouped together into 3 seconds. The first section is for regular imports from the standard library. The second is for import Env;
import HTTP;
import Sockets;
from Argparse import Parser;
from "standard_model/particles.du" import Boson;
from "standard_model/particles.du" import Quark; Mixed CapsThe naming convention in Dictu is to use mixed caps, Camel Case and Pascal Case, to write multiword names. ConstantsConstants should be defined using snake case. E.g. Control FlowDictu provides a number of control structures allowing for robust functionality. These strcutures should be formatted as follows: if () {
// code
} while () {
// code
} for (...) {
// code
} Error HandlingThe const val = someFunc().match(
def(result) => result,
def(error) {
print(error);
System.exit(0);
}
); const ret = someFunc();
if (not ret.success()) {
// do something with the error
ret.unwrapError();
} |
Is there an existing issue for this?
Is your feature request related to a problem?
Most languages have some form of a style guide helping users write idiomatic and stylistically correct code. I was hoping to maybe start the conversation around having such a guide for Dictu.
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: