final methods by default
Dude via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 20 17:00:34 PDT 2015
On Friday, 20 March 2015 at 23:47:37 UTC, Daniel Kozak wrote:
>
> On Fri, 20 Mar 2015 16:27:04 -0700
> Jonathan M Davis via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com>
> wrote:
>
>> On Friday, March 20, 2015 23:53:14 Daniel Kozak via
>> Digitalmars-d-learn wrote:
>> >
>> > On Fri, 20 Mar 2015 22:11:51 +0000
>> > weaselcat via Digitalmars-d-learn
>> > <digitalmars-d-learn at puremagic.com> wrote:
>> >
>> > > On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:
>> > > > Why aren't methods of class final by default?
>> > >
>> > > history
>> > >
>> > > use final class, it should devirtualize all methods.
>> > > see:
>> > > https://github.com/D-Programming-Language/dmd/pull/4427
>> >
>> > Yes, but you can not extend final class. Ok you can still
>> > use UFCS but it
>> > is not elegand solution.
>>
>> Then you can just do
>>
>> class Foo
>> {
>> final:
>> // methods...
>> }
yes only if I want all methods be virtual and without any other
members:
class C {
final:
string field;
}
does not work.
>> or
>>
>> class Foo
>> {
>> final
>> {
>> // methods...
>> }
>> }
Not usefull, I rarely have more than a few final function
following one by one.
>>
>> And even if you couldn't do that, you could always mark each
>> function with
>> final individually.
>>
Definitely the best way (in my cases).
More information about the Digitalmars-d-learn
mailing list