digitalmars.D - Re: The Sweet With
- Tomasz Sowiński <tomeksowi wp.pl> Mar 05 2009
- Sergey Gromov <snake.scaly gmail.com> Mar 05 2009
Walter Bright Wrote:It looks nice, but has a subtle and disastrous problem. In D, arguments are fully resolved *before* overloading is done. If some of the overloads have with declarations, then there's a nightmarish problem of trying to mix overloading and argument resolution together.
Not sure if I understand right. Can you write up a simple example of the nightmare? Tomek
Mar 05 2009
Thu, 05 Mar 2009 07:38:23 -0500, Tomasz Sowiński wrote:Walter Bright Wrote:It looks nice, but has a subtle and disastrous problem. In D, arguments are fully resolved *before* overloading is done. If some of the overloads have with declarations, then there's a nightmarish problem of trying to mix overloading and argument resolution together.
Not sure if I understand right. Can you write up a simple example of the nightmare? Tomek
I think Walter means that types of argument expressions are determined first, and only then a set of compatible overloads is composed. Say you have enum Foo { one, two } int one; void bar(int x); // (1) void bar(with Foo x); // (2) bar(one); Currently, D will determine that expression 'one' is of type int, then search for bar(int) or compatible, and will find (1). With your proposal, you must first find all 'bar's, determine that *some* of them have 'with' arguments, and now what? Infer type for the first argument differently for (1) and (2), so that for (1) it's int, and for (2) it's Foo? Or add the Foo to the scope, so that the first argument is of type Foo even for (1)? I can't see a good solution.
Mar 05 2009