[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.1.7 Local definitions

Definitions can be made local to an expression by enclosing them in a `let within' clause.

 
primes =
  let
    factors(n)  = < m | m <- <2..n-1>, n%m == 0 >
    is_prime(n) = null(factors(n))
  within < n | n <- <2..>, is_prime(n) >

Local definitions are mutually recursive, just like top-level definitions. Not all definitions can be scoped in this way: channel and datatype definitions are only permitted at the top-level. Transparent definitions can be localised, and this can be used to import FDR2's compression operations on a selective basis. For example,

 
my_compress(p) =
  let
    transparent normal, diamond
  within normal(diamond(p))



Formal Systems (Europe) Ltd FDR2 Manual