[Issue 2913] aliasing a ref type is not possible

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 23 10:45:14 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2913


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-23 10:45:12 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > I'm not sure allowing that alias is a good idea, as ref int and int still name
> > the same type. If that alias worked, wouldn't you expect
> > 
> > alias ref int rint;
> > int i = 3;
> > rint ri = i;
> > ri = 4;
> > assert(i == 4);
> > 
> 
> The ref would be only effective in a function signature.

So would that code error at compile-time or just silently compile and fail at
runtime as if the ref didn't exist? It's tricky business..

But there's definitely a problem of not being able to pass around 'ref' in
metaprogramming. The classic example being std.signal, where you can't define a
signal with ref parameters:

struct S
{
    // would allow connecting to 'void f(ref int) { }'
    mixin Signal!(ref int);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list