252
edits
Carandraug (talk | contribs) (→Namespace: explain reasons why we don't indent namespace) |
|||
Line 23: | Line 23: | ||
=== Namespace === | === Namespace === | ||
All code should be in the octave namespace | All code should be in the octave namespace. This is an ongoing project. We | ||
are still moving existing classes into namespaces but all new classes | are still moving existing classes into namespaces but all new classes | ||
should go somewhere into octave | should go somewhere into the "octave" namespace. There is 1 extra level for namespaces | ||
inside octave to be used with care, we don't want too many namespaces. | inside octave to be used with care, we don't want too many namespaces. | ||
Ask before creating a new namespace. | Ask before creating a new namespace. | ||
* | * Indent namespaces as any other block. Emacs and other editors can do this automatically. | ||
* Define namespace on the .cc files; | * Define namespace on the .cc files; | ||
* Do not use "using X" directives; | * Do not use "using X" directives; | ||
Line 39: | Line 35: | ||
{{Code|namespace style on a .h file|<pre> | {{Code|namespace style on a .h file|<pre> | ||
// Note | // Note indentation | ||
namespace octave | namespace octave | ||
{ | { | ||
namespace math | namespace math | ||
{ | { | ||
class foo | |||
class foo | { | ||
{ | public: | ||
public: | foo (...); | ||
}; | |||
} | |||
}; | |||
} | |||
} | } | ||
</pre>}} | </pre>}} | ||
{{Code|namespace style on a .cc file|<pre> | {{Code|namespace style on a .cc file|<pre> | ||
// Note | // Note indentation and that functions are not defined | ||
// as "octave::math::foo:foo" | // as "octave::math::foo:foo" | ||
namespace octave | namespace octave | ||
{ | { | ||
namespace math | namespace math | ||
{ | { | ||
foo::foo (...) | |||
foo::foo (...) | { | ||
{ | ...; | ||
} | |||
} | } | ||
} | |||
} | } | ||
</pre>}} | </pre>}} |