Thread overview
[Issue 6614] New: std.traits should have an isFinal template
Sep 06, 2011
timon.gehr@gmx.ch
Dec 02, 2012
Andrej Mitrovic
Dec 02, 2012
Andrej Mitrovic
Dec 27, 2012
Andrej Mitrovic
Jan 22, 2013
Andrej Mitrovic
Jan 23, 2013
timon.gehr@gmx.ch
Jan 25, 2013
Andrej Mitrovic
September 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6614

           Summary: std.traits should have an isFinal template
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2011-09-06 16:22:20 PDT ---
std.traits should have an isFinal template which indicates if a class type or member function is final.

class A{}
final class B{}

static assert(!isFinal!A && isFinal!B);


class C{int foo();}
class D{final int foo();}

static assert(!isFinal!(C.foo) && isFinal!(D.foo));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6614


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

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


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-02 09:56:01 PST ---
We do have a trait for this:

class A{}
final class B{}

void main()
{
    static assert(!__traits(isFinalClass, A));
    static assert(__traits(isFinalClass, B));
}

Not too sure if it's worth having it as a template in std.traits?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6614



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-02 09:57:00 PST ---
For functions there's:

__traits(isFinalFunction, ...)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6614



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-27 12:59:59 PST ---
So is the idea of the enhancement just to merge the two traits under a single name via Phobos templates?

E.g. (using overloads):

import std.traits;

template isFinal(T) if (is(T == class))
{
    enum bool isFinal = __traits(isFinalClass, T);
}

template isFinal(alias T) if (isSomeFunction!T)
{
    enum bool isFinal = __traits(isFinalFunction, T);
}

class C
{
    void nf() { }
    static void sf() { }
    final void ff() { }
}

final class FC { }

static assert(!isFinal!(C.nf));
static assert(!isFinal!(C.sf));
static assert(isFinal!(C.ff));
static assert(!isFinal!(C));
static assert(isFinal!(FC));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6614


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Linux                       |All


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-22 15:11:14 PST ---
Ping! :]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6614



--- Comment #5 from timon.gehr@gmx.ch 2013-01-23 01:17:10 PST ---
(In reply to comment #4)
> Ping! :]

Yes, looks good.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6614


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com


--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-25 15:00:11 PST ---
https://github.com/D-Programming-Language/phobos/pull/1099

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6614



--- Comment #7 from github-bugzilla@puremagic.com 2013-01-26 20:32:40 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/40cca46b4289dab8a072fa6ed9188347b2579db4 Fixes Issue 6614 - Add isFinalFunction and isFinalClass.

Add isAbstractClass to mirror __traits().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6614


Alex Rønne Petersen <alex@lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex@lycus.org
         Resolution|                            |FIXED


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