3.4. Declarations

When the body of a declaration spans multiple lines, start the body on a new line after the = symbol, and indent the entire body.

def f(x,y) =
    declaration
    declaration
    body expression

Apply this style recursively; if a def appears within a def, indent its contents even further.

def f(x,y) =
    declaration
    def helper(z) =
    	declaration in helper
    	declaration in helper
    	body of helper
    declaration
    body expression

3.4.1. Ambiguous Declarations

The following situation could introduce syntactic ambiguity: the end of a declaration (def or val) is followed by an expression that starts with a non-alphanumeric symbol. Consider these example programs:

def f() =       
  def g() = h
  (x,y)

def f() =      
  val t = h
  (x,y)

def f() =       
  val t = u
  -3

(x,y) may be interpreted as the parameter list of h, and -3 as continuation of u, or they may be regarded as completely separate expressions (in this case, the goal expression of def f). To avoid this ambiguity, Orc imposes the following syntactic constraint:

An expression that follows a declaration begins with an alphanumeric symbol

To circumvent this restriction, if (x,y) is an expression that follows a declaration, write it as # (x,y). Similarly, write # -3, in case -3 is the goal expression in the above example. Note that there are many solutions to this problem; for example using signal >> (x,y) or stop | (x,y) is also valid.