How to check member function for being @disable?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 13 11:08:28 PDT 2016


On Tuesday, September 13, 2016 17:59:09 Adam D. Ruppe via Digitalmars-d-learn 
wrote:
> On Tuesday, 13 September 2016 at 17:52:48 UTC, Jonathan M Davis
>
> wrote:
> > It's really intended for disabling features that would normally
> > be there. I don't know why it would ever make sense to @disable
> > a normal function.
>
> Consider the case of `alias this` or a mixin template. You might
> make a wrapper type that disables a particular operation by
> writing `@disable void opBinary(op)` so it won't forward to the
> underlying thing.

Ah. That makes sense. Thanks for pointing out that use case.

And actually, I think that that use case further supports the idea that what
code should be testing for is whether an operation works and not whether
it's @disabled. In the general case, you don't even have any guarantee that
the type being aliased has an operation that would need to be @disabled. And
from the caller's perspective, it shouldn't matter whether the + operator
doesn't work because it wasn't declared or because it was @disabled.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list