Skip to content

Instantly share code, notes, and snippets.

@philiplaureano
Created March 31, 2013 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philiplaureano/5279046 to your computer and use it in GitHub Desktop.
Save philiplaureano/5279046 to your computer and use it in GitHub Desktop.
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