Diablo is under development and is not functional yet.

Style Guide

  1. Introduction
  2. Code Layout
    1. Indentation
    2. Tabs or Spaces
    3. Maximum Line Length
  3. Single and Double Quotes
  4. Comments
    1. Documentation Strings
  5. Naming Conventions
    1. Case Convention
    2. File Extension

Introduction

This style guide defines the expected coding conventions to be implemented when using the Diablo programming language. The style guide may evolve over time as the language evolves. Adhere to project-specific styling specifications before using this guide.

Code Layout

Indentation

Use 2 spaces per indentation level.

Tabs or Spaces

Use spaces.

Maximum Line Length

Lines should remain under 80 characters.

Single and Double Quotes

Use single quotes for single characters and double quotes for strings.

Comments

Use comments only when the code is not self-documenting. However, one should consider refactoring if the code does not naturally self-document. If comments are still deemed necessary, ensure that they explain why code exists, not how the code is implemented.

Documentation Strings

Documentation strings should be formatted in the following order:

  1. Function Description
  2. Argument(s)
  3. Return Value

All three docstring sections are required except when a function has zero parameters. In this case, the Argument(s) section can be omitted. As seen in the example, including a space between each docstring section is required.

/// Calculate the sum of two numbers.
///
/// foo: float = Description of the first parameter
/// bar: float = Description of the second parameter
///
/// return: float = Sum of first two arguments.
fn foobar(foo, bar) {
    var baz = foo + bar;
    return baz;
}

Naming Conventions

Case Convention

Use snake case (i.e. foo_bar) for files, functions, variables, and anything else not explicity listed here.

Use Pascal case (i.e. FooBar) for class definitions.

File Extension

All Diablo source files should end with .dbl.

Reference

Version

  • Stable: v0.0.0 (TBD)