singalen: (elvish_piper)
[personal profile] singalen
Вы знали? Я не знал.
В C# 2.0 есть closures (у Джо Уолнса). Прочитано у классика. У него достаточно немного коротких статей и их все стоит прочесть.

Обратите внимание на область видимости переменных:
public List<Employee> HighPaid(List<Employee> emps) {
  int threshold = 150;
  return emps.FindAll(delegate(Employee e) { 
    return e.Salary > threshold; 
  });
}
Ушёл выпить й учить матчасть.
upd: интересная цитата об аргументах против closures в Java - о выделении памяти. По ссылке от Фаулера же, в архиве Guy Steele:
One of the early design principles of Java was that heap allocation occurrs if and only if a construct involving the "new" keyword is executed. Adding full-blown closures violated this design principle. (Dynamic class loading also violated the principle, but users seemed to be comfortable with that, perhaps because they believed that "once the computation got going" no more heap allocation would occur.)
Other features for Java release 1.5 will perform certain kinds of autoboxing, which also violates the design principle. This fact will make it easier to argue for restoring full-blown support for closures in the future.


upd2: Зато в .NET нет unordered container (set-а), и такие клёвые Find()/FindAll() не существуют в IList. Отстой!
(deleted comment)
(deleted comment)

(no subject)

26/8/06 17:09 (UTC)
Posted by [identity profile] stepancheg.livejournal.com
Неделю назад в Java-таки решили добавить closures (http://blogs.sun.com/ahe/entry/full_disclosure). Знаете, да?

(no subject)

28/8/06 08:56 (UTC)
Posted by [identity profile] stepancheg.livejournal.com
Ну, предложение не кого-то, а Гослинга и других больших людей. А уж если они предложили, значит так и будет.

Про то, что их собираются ввести в 1.7 я впервые услышал 3 дня назад. Удивляюсь вашей осведомлённости.