From Seo Wiki - Search Engine Optimization and Programming Languages
|It has been suggested that Method signature and Signature (computer science) be merged into this article or section. (Discuss)|
In computer science, a type signature defines the inputs and outputs for a function, subroutine or method. A type signature includes at least the function name and the number of its arguments. In some programming languages, it may also specify the function's return type, the types of its arguments, or errors it may pass back.
A type signature in the Haskell programming language is written, generally, in the following format:
functionName :: arg1Type -> arg2Type -> ... -> argNType
Notice that the type of the result can be regarded as everything past the first supplied argument. This is a consequence of currying, which is made possible by Haskell's support for first-class functions. That is, given a function that takes in two inputs, but had one argument supplied, the function is "curried" to produce a function of one argument—the one that is not supplied. Thus calling f(x), where f :: a -> b -> c, yields a new function f' :: b -> c which can be called f'(b) to produce c.
The actual type specifications can consist of an actual type, such as Integer, or a general type variable that is used in parametric polymorphic functions, such as "a", or "b", or "anyType". So we can write something like:
functionName :: a -> a -> ... -> a
Since Haskell supports higher-order functions, functions can be passed as arguments. This is written as:
functionName :: (a -> a) -> a
This function takes in a function with type signature a -> a, and returns data of type "a" out.
In the Java virtual machine, internal type signatures are used to identify methods and classes at the level of the virtual machine code.
String String.substring(int, int) is represented as Ljava/lang/String/substring(II)Ljava/lang/String;
char c; double d; int retVal = (*fPtr)(c, d);
has the signature:
int (*fPtr)(char c, double d);
|File:HelloWorld.svg||This programming language-related article is a stub. You can help Wikipedia by expanding it.|