Is there a programming language that performs currying when named parameters are omitted?
Posted
by Adam Gent
on Stack Overflow
See other posts from Stack Overflow
or by Adam Gent
Published on 2010-06-10T13:53:09Z
Indexed on
2010/06/10
14:02 UTC
Read the original article
Hit count: 279
programming-languages
|functional-programming
|language-design
|currying
|named-parameters
Many functional programming languages have support for curried parameters. To support currying functions the parameters to the function are essentially a tuple where the last parameter can be omitted making a new function requiring a smaller tuple.
I'm thinking of designing a language that always uses records (aka named parameters) for function parameters.
Thus simple math functions in my make believe language would be:
add { left : num, right : num } = ...
minus { left : num, right : num } = ..
You can pass in any record to those functions so long as they have those two named parameters (they can have more just "left" and "right").
If they have only one of the named parameter it creates a new function:
minus5 :: { left : num } -> num
minus5 = minus { right : 5 }
I borrow some of haskell's notation for above.
Has any one seen a language that does this?
© Stack Overflow or respective owner