Complex Meta Programming

BCS ao at pathlink.com
Sun May 18 13:00:22 PDT 2008


Reply to Manfred,

> In http://www.digitalmars.com/webnews/newsgroups.php?
> art_group=digitalmars.D.learn&article_id=12478
> BCS describes an example for which more complex features in the
> metalanguage seem to be a requirement, if one wants to have short
> compile times.



> Is the current approach good enough?

My fist thought is no, it would be nice to have something better.

In the case cited, I'd love to have a way to have the return type computed 
based on what I try to return (like in a delegate literal).

However on second though it crops up that in this case, my case it would 
not be enough, take this code for example

auto Foo(A,B)(A a, B b)
{
  if(a<b)
    return Foo(++a, --b);
  else if(a == b)
    return b;
  else
    return a;
}

The type of Foo is dependent on the type of Foo. DMD would need to detect 
this and resolve it (by noticing that Foo's return need only be the Closet 
common base of A and B).

Another solution would be to provide a mechanism to detect cyclical definitions 
(a static CyclicTemplae predicate or something) that would allow the program 
to handle this themselves.

I guess the up shot of this is that I don't think ad-hoc additions will be 
a good idea. If we are going to look into more construct, we need to do some 
"real design" on them.





More information about the Digitalmars-d mailing list