In Haskell function type (->) is given, it’s not an algebraic data type constructor and one cannot re-implement it to be identical to (->).
So I wonder, what languages will allow me to write my version of (->)? How does this property called?
UPD Reformulations of the question thanks to the discussion:
Which languages don’t have -> as a primitive type?
Why -> is necessary primitive?
Do you mean meta-circular evaluators like in SICP? Being able to write your own DSL? If you create your own “function type”, you’ll have to take care of “applying” it, yourself.
Just as an example, you could create your own “function” in C for instance, with a look-up table holding function pointers, and use integers as functions. You’d have to provide your own “call” function for such “functions”, of course:
You’d also probably want some means of creating more complex functions from primitive ones, for instance using arrays of ints to signify sequential execution of your “primitive functions”
1, 2, 3, ...and end up inventing whole new language for yourself.I think early assemblers had no ability to create callable “macros” and had to use GOTO.
You could use trampolining to simulate function calls. You could have only global variables store, with shallow binding perhaps. In such language “functions” would be definable, though not primitive type.
So having functions in a language is not necessary, though it is convenient.
In Common Lisp
defunis nothing but a macro associating a name and a callable object (thoughlambdais still a built-in). In AutoLisp originally there was no special function type at all, and functions were represented directly by quoted lists of s-expressions, with first element an arguments list. You can construct your function through use ofconsandlistfunctions, from symbols, directly, in AutoLisp:Some languages (like Python) support more than one primitive function type, each with its calling protocol – namely, generators support multiple re-entry and returns (even if syntactically through the use of same
defkeyword). You can easily imagine a language which would let you define your own calling protocol, thus creating new function types.Edit: as an example consider dealing with multiple arguments in a function call, the choice between automatic currying or automatical optional args etc. In Common LISP say, you could easily create yourself two different
callmacros to directly represent the two calling protocols. Consider functions returning multiple values not through a kludge of aggregates (tuples, in Haskell), but directly into designated recepient vars/slots. All are different types of functions.