November 30
On Friday, 30 November 2018 at 16:54:43 UTC, Paul Backus wrote:
> [snip]
> UDAs attach to symbols, not values, so x will never have a @noAutodecode attribute, no matter what arguments you pass to foo.

Yeah you're right. Putting the attribute on the function parameter gives the parameter that attribute (the function spec says to look at the UDA spec and then that doesn't really say anything about function parameters).  It doesn't require that the parameter has that attribute.

The only thing I could think of was doing it with an alias, but it's a little too ugly to get the right behavior. Maybe there's a more elegant way?

import std.traits : hasUDA;
import std.stdio : writeln;

struct noAutodecode {};

void foo(alias x, T)(T y)
    if (hasUDA!(x, noAutodecode))

void foo(alias x, T)(T y)
    if (!hasUDA!(x, noAutodecode))

void main() {
    string a = "xyz";
    @noAutodecode string b = "zyx";
    foo!(a, string)(a);
    foo!(b, string)(b);
December 04
On Wednesday, 28 November 2018 at 00:12:15 UTC, Walter Bright wrote:
> It seems we're not the only group struggling with this issue. Food for thought, and some controversy:

Every word Rich wrote there is true... Again he proves (again) he is a true genius...
Next ›   Last »
1 2 3 4 5 6