Created
March 31, 2013 00:58
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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