language/documentation/book/src/coding-conventions.md
This section lays out some basic coding conventions for Move that the Move team has found helpful. These are only recommendations, and you should feel free to use other formatting guidelines and conventions if you have a preference for them.
FixedPoint32, VectorCoin, RoleIddestroy_emptyREQUIRES_CAPABILITYT or Element for the Vector generic type parameter. Most of the time the "main" type in a module should be the same name as the module e.g., Option::Option, FixedPoint32::FixedPoint32.Option.moveuse statements should be at the top of the module.as should be used to rename the type locally as appropriate.For example, if there is a module
module Foo {
resource struct Foo { }
const CONST_FOO: u64 = 0;
public fun do_foo(): Foo { Foo{} }
...
}
this would be imported and used as:
module Bar {
use 0x1::Foo::{Self, Foo};
public fun do_bar(x: u64): Foo {
if (x == 10) {
Foo::do_foo()
} else {
abort 0
}
}
...
}
And, if there is a local name-clash when importing two modules:
module OtherFoo {
resource struct Foo {}
...
}
module Importer {
use 0x1::OtherFoo::Foo as OtherFoo;
use 0x1::Foo::Foo;
....
}
///, regular single-line comments //, and block comments /* */The Move team plans to write an autoformatter to enforce formatting conventions. However, in the meantime:
script and address blocks whose contents should not be indented