www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9511] New: [enh] overloading on attributes

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

           Summary: [enh] overloading on attributes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code dawg.eu



void foo()  safe
{
}

void foo() nothrow
{
}

void bar()  safe
{
    foo();
}

void bar() nothrow
{
    foo();
}

----
This currently fails, because foo() is said to match both functions,
but at the same time it is not an error to declare the overloads.
The enhancement is to use attribute sets to resolve overloads.

- The attribute set of the caller must be a subset of the callee.
- The attribute sets of overloads must be disjoint if they have the
  same signature otherwise.
----
Some C++ AMP work has been done on this topic for restrict overloading.
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/03/29/function-overloading-with-restrict-in-c-amp.aspx

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9511


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PST ---
I don't think that it's going to work to overload on any of these attributes.
They're inferred for templated functions, which means that the functions being
used within a function must have their  safety, purety, and nothrow-ity
determined before they're determined for the function itself. So, you can't
reasonably determine an overload of nothrow,  safe, or pure based on the
caller. It has to be based on the arguments (which is _always_ how function
overloading is determined).

Rather, it would be better to make it so that overloads with the same
parameters are illegal.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9511




 They're inferred for templated functions
Right, I didn't thought of inference. But couldn't it still work with the non-inferred original type. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9511




 Rather, it would be better to make it so that overloads with the same
parameters are illegal. Yes, that would be one solution, but I do think this could come in handy with UDA. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9511




Sometimes tag dispatching is used for the same purpose but it's not automated
and definitely looses covariance.
http://www.boost.org/community/generic_programming.html#tag_dispatching

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9511




Jacob Carlborg and Andrei found the talk/article I was searching when I opened
this enhancement.

http://www.artima.com/cppsource/codefeaturesP.html

It was mentioned here while talking about using UDA to guarantee non-allocating
functions.

http://forum.dlang.org/post/kjun26$2h00$1 digitalmars.com

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