www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - final class

reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
What does final class Something mean?
I would expect it to mean the same as if every method were final.
Is it true?
May 12 2004
parent reply Sean Kelly <sean f4.ca> writes:
Ivan Senji wrote:

 What does final class Something mean?
 I would expect it to mean the same as if every method were final.

I think this means that the class cannot be derived from, though I couldn't find any documentation on "final" in the spec, besides that it's an attribute. Sean
May 12 2004
next sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Sean Kelly" <sean f4.ca> wrote in message
news:c7tpsa$285g$1 digitaldaemon.com...
 Ivan Senji wrote:

 What does final class Something mean?
 I would expect it to mean the same as if every method were final.

I think this means that the class cannot be derived from, though I couldn't find any documentation on "final" in the spec, besides that it's an attribute.

In an other discussion Walter mentioned that when member function is final it means it can't be overridden. That is the reason why i'm asking: nothing usefull found in the spec :)
 Sean

May 12 2004
prev sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Sean Kelly wrote:

 Ivan Senji wrote:
 
 What does final class Something mean?
 I would expect it to mean the same as if every method were final.

I think this means that the class cannot be derived from, though I couldn't find any documentation on "final" in the spec, besides that it's an attribute. Sean

I think you couldn't find any documentation because there isn't any: D/8646 ----------------------------------------------------- Title: Re: abstract and final Author: "Walter" Date: Fri, 27 Sep 2002 13:22:03 -0700 I need to work on that... "Patrick Down" <pat codemoon.com> wrote in message news:Xns9292E6E308983patcodemooncom 63.105.9.61...
 The page in the D docs

 http://www.digitalmars.com/d/attribute.html

 lists abstract and final but does not document them.

 I assume they are to have similar meaning to Java's
 abstract and final.

I wrote an example to try to figure out how it works with a class. Apparently, putting "final" on a class either makes all members final or prohibits inheriting from that objects. final.d ----------------------------------------------------- /* This example won't compile in with the "final" compiled in: final.d(34): function toString cannot override final function toString */ /+final+/ class A { private char[] name; /+final+/ char[] toString() { return name; } this(char[] s) { name = s; printf("'%.*s' created\n", name); } ~this() { printf("'%.*s' destroyed\n", name); } } class B: A /+ If class A is final this wouldn't work. +/ { char[] name; char[] toString() { return name; } this(char[] s) { super(s); } ~this() { printf("'%.*s' destroyed\n", name); } } void main() { } -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
May 12 2004
parent J Anderson <REMOVEanderson badmama.com.au> writes:
J C Calvarese wrote:

 Sean Kelly wrote:

 Ivan Senji wrote:

 What does final class Something mean?
 I would expect it to mean the same as if every method were final.

I think this means that the class cannot be derived from, though I couldn't find any documentation on "final" in the spec, besides that it's an attribute. Sean

I think you couldn't find any documentation because there isn't any:

http://www.glenmccl.com/perfj_025.htm -- -Anderson: http://badmama.com.au/~anderson/
May 12 2004