Overloading based on attributes - is it a good idea?

Manu turkeyman at gmail.com
Thu May 30 05:24:21 UTC 2019


On Wed, May 29, 2019 at 6:55 AM Mike Franklin via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Tuesday, 28 May 2019 at 16:08:38 UTC, Andrei Alexandrescu
> wrote:
> > int fun(int) pure;
> > int fun(int);
> >
> > pure int gun(int x)
> > {
> >    return fun(x);
> > }
>
> I think it really depends on the attribute.  I haven't thought
> too much about the other attributes, but for `pure` I don't see
> the use case.  If you can make the implementation of `fun(int)`
> pure, why would you need an additional impure implementation?

Right. nothrow is the only one that makes any sense at all to me, I've
thought that overloading on nothrow might be useful once or twice.
Otherwise... pure; like you say, @nogc; signature is always different
anyway, @safe; makes no sense...


More information about the Digitalmars-d mailing list