[Issue 8713] Allow passing arguments to templates in CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 24 11:19:31 PDT 2013


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #3 from Don <clugdbug at yahoo.com.au> 2013-07-24 11:19:29 PDT ---
This idea has some severe problems. For example, this code currently compiles:
---
int foo(int x) { return 1; }

auto bar(int x) 
{
    if (__ctfe)
        return foo(x);
    assert(0);
}

auto baz(int x) { return bar(x); }
-------
But if you changed that to return foo!(x), and defined foo as:

template foo(int x)
{
    static if (x == 0) enum foo = 0.0;
    else enum foo = "abc";    
}

then baz doesn't have a return type -- the return type of baz(0) is different
to the return type of baz(1). You get no idea of this from reading baz() on its
own.

This is merely one of many problems with this idea. Closing this as invalid. At
the very least, it would need a DIP.

-- 
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