programming-languageslanguage-design

Is there a programming language with parameters in the function name


Often code is not as readable as it could be because parameters are always at the end of the function name. Ex.: addDaysToDate(5, myDate).

I thought about a more readable syntax like this:

function add(days)DaysTo(date) {
  // Some implementation
}

var myDate = new Date()
add(5)DaysTo(myDate)

And you could go really crazy:

addA(5)('dollar')CouponTo(order)If(user)IsLoggedIn

So here is my question: Are there any languages that incorporate this concept?


Solution

  • Agda version 2 has this.

    If you declare a function if_then_else_, you can call it in two ways (actually more ways):

    1. a standard application by using the full name if_then_else_ x y z

    2. an operator application by placing the arguments between the name parts if x then y else z, leaving a space between arguments and part names

    Documentation: