in JavaScript:
function getTopCustomersOfTheYear(howManyCustomers, whichYear) {
// Some code here.
}
getTopCustomersOfTheYear(50, 2010);
in C#:
public List<Customer> GetTopCustomersOfTheYear(int howManyCustomers,
int whichYear)
{
// Some code here
}
List<Customer> customers = GetTopCustomersOfTheYear(50, 2010);
in PHP:
public function getTopCustomersOfTheYear($howManyCustomers, $whichYear)
{
// Some code here
}
$customers = getTopCustomersOfTheYear(50, 2010);
Is there any language out there which support this syntax:
function GetTop(x)CustomersOfTheYear(y)
{
// Some code here
}
returnValue = GetTop(50)CustomersOfTheYear(2010);
Isn't it more semantic, more readable form of writing a function?
Update: The reason I'm asking this question is that, I'm writing an article about a new syntax for a new language. However, I thought that having such syntax for declaring methods could be nicer and more friendly to developers and would decrease learning-curve of the language, because of being more closer to natural language. I just wanted to know if this feature has already been contemplated upon or not.
Best Answer
Yes, and yes. Yes there's such a language, and yes, many people find it more readable once they get used to it.
In Objective-C, the method would be:
That's actually a pretty contrived example that doesn't read very well, so here's a better one from actual code:
That the prototype for a method that returns a new UIColor instance using the red, green, blue, and alpha values. You'd call it like this:
Read more about message names with interspersed parameters in The Objective-C Programming Language.