digitalmars.D - final class
- Ivan Senji (3/3) May 12 2004 What does final class Something mean?
- Sean Kelly (5/7) May 12 2004 I think this means that the class cannot be derived from, though I
- Ivan Senji (5/12) May 12 2004 In an other discussion Walter mentioned that when member function is fin...
- J C Calvarese (59/75) May 12 2004 I think you couldn't find any documentation because there isn't any:
- J Anderson (5/19) May 12 2004 You could always look at the documentation for java's final.
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
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
"Sean Kelly" <sean f4.ca> wrote in message news:c7tpsa$285g$1 digitaldaemon.com...Ivan Senji wrote: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 :)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
Sean Kelly wrote:Ivan Senji wrote:I think you couldn't find any documentation because there isn't any: http://www.digitalmars.com/drn-bin/wwwnews?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...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. SeanThe 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
J C Calvarese wrote:Sean Kelly wrote:You could always look at the documentation for java's final. http://www.glenmccl.com/perfj_025.htm -- -Anderson: http://badmama.com.au/~anderson/Ivan Senji wrote:I think you couldn't find any documentation because there isn't any: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