Leakproof - Spicery/Nutmeg GitHub Wiki

In Nutmeg, a procedure is said to be leakproof if it makes no read or write reference, directly or indirectly, to mutable store. Because of this, a leakproof procedure cannot change any mutable store except the store it is passed as input arguments. Nor can its behaviour be modified by external mutation. Being leakproof is an important property in Nutmeg because it means that only the inputs and outputs matter.

For example, this is a leaky procedure. leakyProc is leaky because it references accumulator which is bound to a mutable list.

val accumulator = MutableList()
def leakyProc( x ):
    accumulator.add( x )
end

By contrast, this is a leakproof procedure:

const alphabet = 'abcdefghijklmnopqrstuvwxyz'
[leakproof]
def positionInAlphabet( ch ):
    alphabet.indexOf( ch ) 
end

N.B. If a procedure is not leakproof, it does not necessarily mean that it leaks. It only means we have no automatic assurance it does not leak.