On Thursday, 19 April 2012 at 14:46:26 UTC, Jacob Carlborg wrote:
On 2012-04-19 13:05, Ary Manzana wrote:

Unfortunately rename can't be perfect in D because you can't apply it
inside templates.

Could you elaborate a bit on why this is?

A template can be instantiated in user code with parameters that can't be known at library compile/refactor time (or mixed into, again unknown, scopes), and this can OTOH lead to problems like:

---
int doSomething(int a) {
  return a;
}

auto foo(T)(T t) {
  // User renames doSomething(int) above – should this be
  // changed as well?
  return t.doSomething();
}

unittest {
  assert(foo(3) == 3);
}
---

The question is, though, whether »perfect« renaming support is really required, or if a defensive solution warning on potential ambiguities isn't already useful enough for most cases.

David

Reply via email to