Generic new() constraint
От: _nn_ www.nemerleweb.com
Дата: 24.11.11 16:37
Оценка:
C#
interface IA {}

class M
{
  static void F<T>() where T : IA, new() {} // OK
  static void G<T>() where T : new(), IA {} // The `new()' constraint must be the last constraint specified

  static void Main() {}
}


Nemerle:
interface IA {}
 
module M
{
  F[T]() : void where T : IA, new() {} // OK
  G[T]() : void where T : new(), IA {} // OK
 
  Main() : void {}
}


Почему new() у C# требуется, чтобы стоял в конце ?
Баг Nemerle или наоборот фича ?
http://rsdn.nemerleweb.com
http://nemerleweb.com
Re: Generic new() constraint
От: Ziaw Россия  
Дата: 24.11.11 18:26
Оценка:
Здравствуйте, _nn_, Вы писали:


__>Почему new() у C# требуется, чтобы стоял в конце ?


По спецификации

__>Баг Nemerle или наоборот фича ?


Вот что пишет Липперт по этому поводу:

Indeed, there is a cost to the proposed feature, with little benefit, and opportunity costs. The opportunity costs are not just that time spent doing that feature is taken away from other worthy features; it is also that any time we allow variation in a syntax, that makes it more difficult to extend or modify that syntax in the future


Предлагаю считать фичей nemerle (несущественной).
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.