Overloading based on attributes - is it a good idea?
Jonathan Marler
johnnymarler at gmail.com
Tue May 28 17:20:25 UTC 2019
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);
> }
>
> This doesn't work, but on the face of it it's not ambiguous -
> the second overload of fun() would not compile anyway.
>
> I was wondering whether allowing overloading on attributes in
> general would be a good idea. I suspect templates and attribute
> deduction make that difficult.
I posed this question a few years ago but specifically for @nogc.
Maybe it makes sense for some attributes but not for others? I
think there could be some good use cases for overloading on
@nogc, which would allow you to choose a different implementation
depending on whether the GC is being used or not.
More information about the Digitalmars-d
mailing list