`ref T` should be a type!!

Atila Neves atila.neves at gmail.com
Mon Apr 1 14:02:49 UTC 2019


On Monday, 1 April 2019 at 01:19:41 UTC, Manu wrote:
> On Sun, Mar 31, 2019 at 5:20 PM Walter Bright via Digitalmars-d 
> <digitalmars-d at puremagic.com> wrote:
>>
>> On 3/31/2019 3:48 PM, Manu wrote:
> <snip>
> I don't know how you've never found yourself static-if-ing on 
> ref-ness
> of stuff in every bit of functional meta you've ever written. 
> Ref
> creates an out-of-language (we have no language features to 
> interact
> with 'storage class') suite of conditions that I frequently 
> have to
> wrangle my way through.

One can inspect the ref-ness of function parameters:

---------------
void main() {
     fun(5);
     int i;
     fun(i);
}

void fun(T)(auto ref T value) {
     import std.stdio;
     writeln("T: ", T.stringof, "   ref? ", __traits(isRef, 
value));
}

---------------

Output:

T: int   ref? false
T: int   ref? true


Unfortunately for me, this is a thing though:

https://issues.dlang.org/show_bug.cgi?id=19507

*I* think that's a bug (which is why I filed it), but I'm not 
even sure.



More information about the Digitalmars-d mailing list