dsimcha wrote:
1. Method calls don't need to be virtual.
2. An instance of a subclass cannot be converted to a final instance of the
base class.
3. A final instance can be implicitly converted to a non-final instance, but
the opposite would not work.
Using final as an instance attribute like
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Walter Bright wrote:
> dsimcha wrote:
>> == Quote from Walter Bright (newshou...@digitalmars.com)'s article
>>> dsimcha wrote:
A possible
solution is, given a class:
class Foo {
// Actual implementation.
}
fi
dsimcha wrote:
== Quote from Walter Bright (newshou...@digitalmars.com)'s article
dsimcha wrote:
A possible
solution is, given a class:
class Foo {
// Actual implementation.
}
final class FooFinal : Foo{
// Dummy that just makes Foo final.
}
With dmd:
final class A { }
class B
Reply to dsimcha,
Several people have griped in the past that D class methods are
virtual by default. I've pointed out to them that you can get around
this by making the methods final. However, this is a bit of a blunt
instrument, because some use cases for a single class may call for
polymorp
== Quote from Walter Bright (newshou...@digitalmars.com)'s article
> dsimcha wrote:
> > A possible
> > solution is, given a class:
> >
> > class Foo {
> > // Actual implementation.
> > }
> >
> > final class FooFinal : Foo{
> > // Dummy that just makes Foo final.
> > }
> With dmd:
>final
dsimcha wrote:
A possible
solution is, given a class:
class Foo {
// Actual implementation.
}
final class FooFinal : Foo{
// Dummy that just makes Foo final.
}
With dmd:
final class A { }
class B : A { }
Compiling:
test.d(2): Error: class test.B cannot inherit from final clas
IMHO, this proposal does not go far enough. THose that worry about performance
also care about object size. If a vtable or monitor are needed, then people
will still avoid classes for performance.
dsimcha Wrote:
> Several people have griped in the past that D class methods are virtual by
> defa
Several people have griped in the past that D class methods are virtual by
default. I've pointed out to them that you can get around this by making the
methods final. However, this is a bit of a blunt instrument, because some use
cases for a single class may call for polymorphism and other use ca