Clojure and Pull Request Controversy

jmh530 john.michael.hall at gmail.com
Fri Nov 30 16:05:18 UTC 2018


On Friday, 30 November 2018 at 11:22:04 UTC, Dukc wrote:
> [snip]
>
> Please don't! This will likely cause some third-party libraries 
> to rely on the switch, while some still rely on autodecoding, 
> making them incompatible!
>
> On the other hand, if we can find a way to similarily mark a 
> single module to not autodecode while others still could, then 
> it's a brilliant idea.
>
> Otherwise, I quess we just have to plain deprectate using char 
> arrays as ranges at all, or leave the whole thing as is.

Fair point.

Perhaps UDAs? I can't seem to get it to work with static ifs 
(below). Same thing with template ifs. I tried to do two 
different versions of foo, one as void foo(T)(@noAutodecode T x) 
and the other with same signature as below. The problem is with 
overloads. I can't do void foo(T)(!@noAutodecode T x) and get the 
right behavior. Support for UDAs on function parameters might 
need to get improved to make it convenient, but it seems like a 
natural evolution of the recent change in 2.082.

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
}


More information about the Digitalmars-d mailing list