[First verion of language summary sydow@chalmers.se**20080321145959] { adddir ./summary addfile ./summary/bindings.html hunk ./summary/bindings.html 1 + + +Patterns and bindings + + + + +

Patterns and bindings

+ +

Patterns and pattern matching

+

+Patterns occur in several syntactic contexts in Timber (e.g. in the left hand sides of bindings, lambda expressions +and case alternatives). Syntactically, patterns form a subset of expressions; a pattern is one of the following +

+

+At run-time, patterns are matched against values. Pattern-matching may succeed or fail; in the former case the result +is a binding of the variables in the pattern to values. The rules are as follows: +

+

+ In patterns the special "wildcard" variable _ may be used; in contrast to other variables, it is not bound + by pattern-matching. +

+ A consequence of the way pattern-matching is done is that patterns must be linear; no variable may occur more than once in + a pattern. + +

Bindings

+

+Syntactically, bindings are divided into type signatures and equations. Equations are either function bindings, pattern bindings + or instance bindings for implicit struct types. + +

+

+The order between bindings in a sequence of bindings are not significant, with the following exceptions: +

+

+Function bindings are recursive. For pattern bindings certain limited forms of recursion are possible, in order +to build finite, cyclic data structures. To be described more... + addfile ./summary/default.html hunk ./summary/default.html 1 + + +Default declarations + + + + +

Default declarations

+

+Default declarations come in two distinct forms. They share the keyword default and they both +affect instances for implicit struct types, but otherwise they serve quite different purposes. +