Fun with templates
TommiT
tommitissari at hotmail.com
Sun Jul 7 02:03:33 PDT 2013
On Sunday, 7 July 2013 at 06:22:17 UTC, Manu wrote:
> On 7 July 2013 16:02, TommiT <tommitissari at hotmail.com> wrote:
>> I think Artur's solution is the cleanest one [..]
>
> Maybe so, but I just have my suspicions that it will never fly,
> and I think a solution here is actually pretty important.
You think it won't fly because it's a breaking change? I also
think a solution is needed.
Earlier you said that your suggestion either is implementable or
it isn't. If you put it that way, the answer must be that it is
implementable, because if a problem is computable then it is
possible to write a compiler that can compute it given that
there's an ambiguous solution to the problem. But since compiler
writers are only human, I think there might the third possibility
which is that it's just a too big of an undertaking for a small
group of humans to write that compiler. For example here's an
example where the compiler would need to solve the equation:
cast(int) (3.5 ^^ x * x ^^ 4 + 5 * x) == 206
for x. And not only does the compiler need to figure out an
answer to the problem, it needs to figure out that there aren't
multiple answers to the problem.
struct Soo(int n) { }
template Too(int x)
{
alias Too = Soo!(cast(int) (3.5 ^^ x * x ^^ 4 + 5 * x));
}
void foo(int n)(Too!n) { }
void main()
{
Soo!206 s;
foo(s); // should call foo!2(s)
}
More information about the Digitalmars-d
mailing list