www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2460] New: Ref functions can't be template functions.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2460

           Summary: Ref functions can't be template functions.
           Product: D
           Version: 2.020
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P4
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: hskwk inter7.jp


Ref functions can't be template functions

I guess DMD parser failed to bind `ref' to ref functions if the template is
written in function template syntax.
It is not serious problem for me.


real t;
ref real f(S)(S rhs)
{
        size_t tmp;
        return t;
}

template g(S)
{
        ref real g(S rhs)
        {
                size_t tmp;
                return t;
        }
}

f(1.0);
// variable f!(double).f.tmp only parameters or foreach declarations can be ref

g(1.0)
// no problem


-- 
Nov 18 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2460


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net
           Severity|minor                       |major



11:27:51 PDT ---
Raising importance, since operator overloading is now done with templated
functions, and this will become a major pain in the long run.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2460


Masahiro Nakagawa <repeatedly gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |repeatedly gmail.com



08:59:21 PDT ---
Today, I hit the similar problem.

In the latest dmd, above code works but variadic version doesn't works.

struct Foo
{
    // works! I use this for workaround
    template foo(Args...) if (true)
    {
        ref Foo foo(Args args)
        {
            return this;
        }
    }

    // doesn't work. I want use this!!
    ref Foo foo(Args...)(Args args) if (true)
    {
        return this;
    }

    // works!
    ref Foo foo(Args...)(Args args)
    {
        return this;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2460


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |kennytm gmail.com
         Resolution|                            |FIXED



Looks like this has been fixed. All programs in this page compiles for me. 

--------
struct Foo {
    double x, y;

    ref double get(Args...)(Args args) if (args.length == 4) {
        return x;
    }
}
void main() {
    Foo f;
    f.get(4,5,6,7) = 6;
    assert(f.x == 6);
}
--------

Can we fix this std.complex bug then?

"Some operators, such as opAssign and opOpAssign, should return by ref, but
currently don't. This will be implemented as soon as DMD bug 2460 is fixed."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 23 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2460




02:40:59 PDT ---
Cool! I'll fix std.complex.

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