en JavaScript:
function getTopCustomersOfTheYear(howManyCustomers, whichYear) {
// Some code here.
}
getTopCustomersOfTheYear(50, 2010);
Cía#:
public List<Customer> GetTopCustomersOfTheYear(int howManyCustomers,
int whichYear)
{
// Some code here
}
List<Customer> customers = GetTopCustomersOfTheYear(50, 2010);
en PHP:
public function getTopCustomersOfTheYear($howManyCustomers, $whichYear)
{
// Some code here
}
$customers = getTopCustomersOfTheYear(50, 2010);
¿Hay algún lenguaje que admita esta sintaxis?
function GetTop(x)CustomersOfTheYear(y)
{
// Some code here
}
returnValue = GetTop(50)CustomersOfTheYear(2010);
¿No es una forma más semántica y más legible de escribir una función?
Actualización: la razón por la que hago esta pregunta es que estoy escribiendo un artículo sobre una nueva sintaxis para un nuevo idioma. Sin embargo, pensé que tener esa sintaxis para declarar métodos podría ser mejor y más amigable para los desarrolladores y disminuiría la curva de aprendizaje del lenguaje, debido a que está más cerca del lenguaje natural. Solo quería saber si esta característica ya se ha contemplado o no.
'hello world' indexOf: $o startingAt: 6
o Rectangle width: 100 height: 200
. Por cierto, ¿qué hay de malo en esta pregunta?
returnValue = GetTop(50, CustomersOfTheYear(2010))
lo que me parece igualmente legible, y en realidad más flexible / ortogonal. ... y sí, es una sintaxis normal.