Re: A Modest Proposal: Final class instances

2009-05-05 Thread Stewart Gordon
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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread div0
-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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread Walter Bright
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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread BCS
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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread dsimcha
== 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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread Walter Bright
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

Re: A Modest Proposal: Final class instances

2009-05-05 Thread Jason House
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

A Modest Proposal: Final class instances

2009-05-04 Thread 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 polymorphism and other use ca