Clojure and Pull Request Controversy
Paul Backus
snarwin at gmail.com
Fri Nov 30 16:54:43 UTC 2018
On Friday, 30 November 2018 at 16:05:18 UTC, jmh530 wrote:
> import std.traits : hasUDA, isNarrowString;
> import std.stdio : writeln;
>
> struct noAutodecode {};
>
> void foo(T)(T x)
> if (isNarrowString!T)
> {
> static if (hasUDA!(x, noAutodecode)) {
> writeln(hasUDA!(x, noAutodecode));
> } else {
> writeln(hasUDA!(x, noAutodecode));
> }
> }
>
> void main() {
> string a = "xyz";
> @noAutodecode string b = "zyx";
> foo(a); //prints false
> foo(b); //prints false, expected true
> }
UDAs attach to symbols, not values, so x will never have a
@noAutodecode attribute, no matter what arguments you pass to foo.
More information about the Digitalmars-d
mailing list