www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2876] New: suggest keyword:auto return

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

           Summary: suggest keyword:auto return
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: galaxylang gmail.com


I'm interest in D's metaprogram,surely D is the most powerful language now.
However when i write D program,i found if we can program by this way:

auto ReturnStatic(int i)(int a)
{
   int f1(int b){return a+b;}
   double f2(double c){return c+a;}
   static if(i==0){return &f1;}
   else return &f2;
}

this will be great enhance the language power


-- 
Apr 22 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2876





------- Comment #1 from fvbommel wxs.nl  2009-04-22 07:56 -------
*** Bug 2877 has been marked as a duplicate of this bug. ***


-- 
Apr 22 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2876


fvbommel wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|suggest keyword:auto return |suggest keyword:auto return




------- Comment #2 from fvbommel wxs.nl  2009-04-22 07:57 -------
Isn't this already implemented (in D2)?


-- 
Apr 22 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2876


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com
           Platform|x86                         |All
            Version|unspecified                 |future
            Summary|suggest keyword:auto return |Enhancement to 'auto'
                   |                            |return
         OS/Version|Windows                     |All
           Severity|normal                      |enhancement




--- Comment #3 from Brad Roberts <braddr puremagic.com>  2009-06-08 01:08:39
PDT ---
I doubt the current auto return deduction could handle this code, but I haven't
tried it.

Changing it to an enhancement request for a future version.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 08 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2876


Witold Baryluk <baryluk smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |baryluk smp.if.uj.edu.pl
         Resolution|                            |WORKSFORME


--- Comment #4 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2009-12-26
18:52:06 PST ---
I don't see any problem with this example. It is quite simple to compile, and
in fact it works in DMD 2.037 as desired. This example uses three things which
are fully supported:
 - static if over template parameters, no problem for long time
 - coping/allocating variable on heap if they are used in delegate (or nested
functions) and returned from function (escaping scope), no problem in most
cases
 - infering return type, no problem as we have exactly one return (after static
if selection), and its type is quite "simple"  (it is delegate int(int), or
delegate float(float)), and compiler knows this.


Please close this bug with WORKSFORME.

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