Fully dynamic d by opDotExp overloading

Christopher Wright dhasenan at gmail.com
Fri Apr 17 15:04:51 PDT 2009


Andrei Alexandrescu wrote:
> Cool! I suggest the rewrite:
> 
> c.unknownmethod(args) -> c.opDotExp!("unknownmethod")(args)
> 
> That way you have the option of handling the method name statically or 
> dynamically.

How would that allow you to handle the method name dynamically, if 
you're passing it as a template argument?

You mean that the *callee* can be dynamic. However, the *caller* cannot. 
This would rarely be an issue, I grant, but:

Let's say you have a set of valid arguments for the opDotExp template. 
Why the hell aren't you writing individual methods?!

So opDotExp is nearly useless if you make the method name a template 
argument. The *only* uses are
- blacklisting arguments, with compile-time errors
- requiring that arguments follow a certain (regular) pattern, with 
compile-time errors
- a way to get the __FUNCTION__ macro that's been requested several 
times and not yet implemented



More information about the Digitalmars-d mailing list