Spec sharp
Encyclopedia
Spec# is a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 with specification language
Specification language
A specification language is a formal language used in computer science.Unlike most programming languages, which are directly executable formal languages used to implement a system, specification languages are used during systems analysis, requirements analysis and systems design.Specification...

 features that extends the capabilities of the C# programming language with Eiffel
Eiffel (programming language)
Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method...

-like contracts
Design by contract
Design by contract , also known as programming by contract and design-by-contract programming, is an approach to designing computer software...

, including object invariants, preconditions and postconditions. Like ESC/Java
ESC/Java
ESC/Java , the "Extended Static Checker for Java," is a programming tool that attempts to find common run-time errors in Java programs at compile time...

, it includes a static checking tool based on a theorem prover that is able to statically verify many of these invariants. It also includes a variety of other minor extensions to the language, such as non-null reference types.

The code contracts API in the .NET Framework 4.0
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

 has evolved with Spec#.

Microsoft Research
Microsoft Research
Microsoft Research is the research division of Microsoft created in 1991 for developing various computer science ideas and integrating them into Microsoft products. It currently employs Turing Award winners C.A.R. Hoare, Butler Lampson, and Charles P...

 developed both Spec# and C#; in turn, Spec# serves as the foundation of the Sing#
Sing sharp
Sing# is a concurrent programming language that is a superset of the Spec# programming language; in turn, Spec# is an extension of the C# programming language. Microsoft Research developed Spec#, and later extended it into Sing# in order to develop the Singularity operating system...

 programming language, which Microsoft Research also developed.

Features

See also: Spec# in C Sharp syntax
C Sharp syntax
This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.-Identifier:An identifier is the name of an element in the code. There are certain standard naming conventions to follow when selecting names for elements.An...

.

Spec# extends the core C# programming language with features such as:
  • Non-nullable types
  • Structures for code contract like preconditions and postconditions.
  • Checked exceptions similar to those in Java
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

    .
  • Convenient syntax

Example

This example shows two of the basic structures that are used when adding contracts to your code (try Spec# in your browser).


static void Main(string![] args)
requires args.Length > 0;
{
foreach(string arg in args)
{
Console.WriteLine(arg);
}
}

  • ! is used to make a reference type non-nullable, e.g. you cannot set the value to null. This in contrast of nullable types which allows value types to be set as null.

  • requires indicates a condition that must be followed in the code. In this case the length of args is not allowed to be zero or less.

Sources

  • Barnett, M., K. R. M. Leino, W. Schulte, "The Spec# Programming System: An Overview." Proceedings of Construction and Analysis of Safe, Secure and Interoperable Smart Devices (CASSIS), Marseilles. Springer-Verlag, 2004.

See also

  • Eiffel
    Eiffel (programming language)
    Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method...

  • Singularity
    Singularity (operating system)
    Singularity is an experimental operating system being built by Microsoft Research since 2003. It is intended as a highly-dependable OS in which the kernel, device drivers, and applications are all written in managed code.- Workings :...

  • Sing#
    Sing sharp
    Sing# is a concurrent programming language that is a superset of the Spec# programming language; in turn, Spec# is an extension of the C# programming language. Microsoft Research developed Spec#, and later extended it into Sing# in order to develop the Singularity operating system...

  • C#

External links

  • Spec# website from Microsoft Research
    Microsoft Research
    Microsoft Research is the research division of Microsoft created in 1991 for developing various computer science ideas and integrating them into Microsoft products. It currently employs Turing Award winners C.A.R. Hoare, Butler Lampson, and Charles P...

  • Spec# at Codeplex
  • Online Spec# at RiSE4fun
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK