The Sacalon Style



Whitespace

  • One statement per line.
  • Use spaces instead of hardware tabs.
  • Each indentation level will be four columns.

Naming Conventions

Unless listedVariable names should be camelCased. So, names formed by joining multiple words have each word other than the first word capitalized. Also Function names should be split with an underscore(`_`).

function myFunc()
var myLocalVar : int?
Sacalon

Module and package names should be all lowercase, and only contain the characters [a..z][0..9][_]. This avoids problems when dealing with case-insensitive file systems.

use ctypto.sha256
Sacalon

The names of user-defined types should be PascalCased, which is the same as camelCased except that the first letter is uppercase.

struct FooAndBar {
    var x = 0
}
enum Colors{
    red,
    blue,
    green
}
Sacalon

The names of constants should be CAPITALCASED.

const PI : float = 3.14
Sacalon

If a name would conflict with a keyword, and it is desirable to use the keyword rather than pick a different name, a single underscore ‘_’ should be appended to it. Names should not be capitalized differently in order to avoid conflicting with keywords.

enum Types{
    string_,
    int_,
    float_
}
Sacalon


Variable Declaration

Always assign a value to variables when you declare they and decrease using nullable variable in your program.

var localVar : int = 12 // good
var localVar2 : int? // bad
localVar2 = 12
Sacalon


Imports

  • Local imports should be preferred over global imports.
  • Imports should be sorted lexicographically.

We are not necessarily recommending that all code follow these rules but sent PRs to Sacalon standard library should should use these rules.
Do you have a suggestion to improve these rules or an idea for new rules? open an issue on Sacalon's github repository.