Create a gist now

Instantly share code, notes, and snippets.

An example of how you can use Design by Contract macros and Non-nullable type macros in Nemerle to write more reliable code
public FlushContentsTo([NotNull] outputStream : Stream) : uint
requires outputStream.CanWrite
{
def startPosition = 0;
_heap.Seek(startPosition);
outputStream.Seek(startPosition);
def bytes = _heap.ToArray();
def writer = BinaryWriter(outputStream);
writer.Write(bytes);
startPosition :> uint;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment