Fully dynamic d by opDotExp overloading

Nick Sabalausky a at a.a
Sat Apr 18 00:32:54 PDT 2009


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:gsav4n$2ij4$1 at digitalmars.com...
>
> It's a good question. opDotExp leaves more flexibility because it allows 
> for a host of compile-time manipulations, e.g. decide to forward to a 
> member etc. Also consider this (probably Nick will turn blue):
>
> struct Pascalize(T)
> {
>     T m;
>     auto opDotExp(string name, T...)(T args)
>     {
>         return mixin("m."~tolower(name))(args);
>     }
> }
>
> struct S { void foo() { ... } }
>
> Pascalize!S s;
> s.foo(); // works
> s.Foo(); // works too
> s.fOo(); // yup, works again
>

It's really late, so I can't come up with much coherent thought, but:

1. Ick.

2. Wasn't the potential for just that sort of abuse a big part of the reason 
for ditching #define?

3.
struct F { void fooBar() { ... } }
Pascalize!F f; // Can't invoke shit!
// Don't ask me what point I'm trying to make with that,
// I don't even know, myself.






More information about the Digitalmars-d mailing list