Skip to content
skaller edited this page Apr 13, 2011 · 2 revisions

(Partially cribbed from Scala style guide for now).

Table of Contents

80 Column Limit

Indention

Indentation should follow the "2-space convention". This:

    fun foo (x:int) = {
      val y = x + 1;
      return y;
    }

Not this:

    fun foo (x:int) = {
        val y = x + 1;
        return y;
    }

No tab characters.

Line Wrapping

Indent 2 lines:

    val result = 1 + 2 + 3 + 4 + 5 + 6 +
      7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +
      15 + 16 + 17 + 18 + 19 + 2
    ;

Variables

Lower case, use underscores for multiword names.

Type Parameters

Single upper letter.

  fun f[U,V] (x:U, y:V) => x,y;

Type Deduction

Use type deduction as much as possible. This:

    val x = 5;

Not this:

    val x:int = 5;

Functions and Procedures

Function and procedure types should be declared with a space between the parameter type, the arrow, and the return type.

    fun foo (f: int -> string): int = { .. }
    proc bar (f: (bool * double) -> string) { ...}