digitalmars.D.learn - final methods by default
- ref2401 (1/1) Mar 20 2015 Why aren't methods of class final by default?
- John Colvin (3/4) Mar 20 2015 Because of a design choice to maximise usage flexibility that is
- Gary Willoughby (2/3) Mar 20 2015 See: http://forum.dlang.org/thread/lfqoan$5qq$1@digitalmars.com
- weaselcat (4/5) Mar 20 2015 history
- Daniel Kozak via Digitalmars-d-learn (4/11) Mar 20 2015 Yes, but you can not extend final class. Ok you can still use UFCS but i...
- Jonathan M Davis via Digitalmars-d-learn (21/32) Mar 20 2015 Then you can just do
- Daniel Kozak via Digitalmars-d-learn (5/42) Mar 20 2015 On Fri, 20 Mar 2015 16:27:04 -0700
- Dude (11/56) Mar 20 2015 yes only if I want all methods be virtual and without any other
On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Why aren't methods of class final by default?Because of a design choice to maximise usage flexibility that is questionable but not likely to change.
Mar 20 2015
On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Why aren't methods of class final by default?See: http://forum.dlang.org/thread/lfqoan$5qq$1 digitalmars.com
Mar 20 2015
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
Mar 20 2015
On Fri, 20 Mar 2015 22:11:51 +0000 weaselcat via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Yes, but you can not extend final class. Ok you can still use UFCS but it is not elegand solution.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
Mar 20 2015
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 puremagic.com> wrote:Then you can just do class Foo { final: // methods... } or class Foo { final { // methods... } } And even if you couldn't do that, you could always mark each function with final individually. Yes. final should probably be the default, but unfortunately, that's not the choice that was made early on, and it was decided later that the change wasn't worth the breakage. But it can be worked around easily enough. - Jonathan M DavisOn Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Yes, but you can not extend final class. Ok you can still use UFCS but it is not elegand solution.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
Mar 20 2015
On Fri, 20 Mar 2015 16:27:04 -0700 Jonathan M Davis via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Friday, March 20, 2015 23:53:14 Daniel Kozak via Digitalmars-d-learn wrote:Yes I know that and use it. Not often because I use struct and templates so I need to marks methods as final occasionally ;-)On Fri, 20 Mar 2015 22:11:51 +0000 weaselcat via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Then you can just do class Foo { final: // methods... } or class Foo { final { // methods... } } And even if you couldn't do that, you could always mark each function with final individually.On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Yes, but you can not extend final class. Ok you can still use UFCS but it is not elegand solution.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
Mar 20 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 puremagic.com> wrote:yes only if I want all methods be virtual and without any other members: class C { final: string field; } does not work.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 puremagic.com> wrote:Then you can just do class Foo { final: // methods... }On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote:Yes, but you can not extend final class. Ok you can still use UFCS but it is not elegand solution.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/4427Not usefull, I rarely have more than a few final function following one by one.or class Foo { final { // methods... } }Definitely the best way (in my cases).And even if you couldn't do that, you could always mark each function with final individually.
Mar 20 2015