Programming Languages
The following table summarized the syntax used for function types in several programming languages, including an example type signature for the higher-order function composition function:
Language | Notation | Example type signature | |
---|---|---|---|
With first-class functions, parametric polymorphism |
C++11 | std::function<ρ (α1,α2,...,αn)> |
function |
C# | Func<α1,α2,...,αn,ρ> |
Func compose(Func f, Func g); |
|
Go | func(α1,α2,...,αn) ρ |
var compose func(func(int)int, func(int)int) func(int)int |
|
Haskell | α -> ρ |
compose :: (a -> b) -> (b -> c) -> a -> c |
|
Objective-C/C/C++ with Blocks | ρ (^)(α1,α2,...,αn) |
int (^compose(int (^f)(int), int (^g)(int)))(int); |
|
OCaml | α -> ρ |
compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c |
|
Scala | (α1,α2,...,αn) => ρ |
def compose(f: B => C, g: A => B): A => C |
|
Standard ML | α -> ρ |
compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c |
|
Without first-class functions, parametric polymorphism |
C | ρ (*)(α1,α2,...,αn) |
int (*compose(int (*f)(int), int (*g)(int)))(int); |
When looking at the example type signature of for example C#, one should note that the type of the function compose
is actually Func
.
Read more about this topic: Function Type
Famous quotes containing the words programming and/or languages:
“If there is a price to pay for the privilege of spending the early years of child rearing in the drivers seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.”
—Melinda M. Marshall (20th century)
“The very natural tendency to use terms derived from traditional grammar like verb, noun, adjective, passive voice, in describing languages outside of Indo-European is fraught with grave possibilities of misunderstanding.”
—Benjamin Lee Whorf (18971934)