Re: Pre-PPC: class :abstract
[email protected] (Branislav Zahradník)
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <CAB=rbOnGMLqTGpqabwz4gb75q4OeovRu8DnQkUMYjNSRJ4+crA@mail.gmail.com> |
On Fri, 19 Dec 2025 at 11:59, Ovid <[email protected]> wrote: > On Wed, Dec 17, 2025 at 3:47 PM Branislav Zahradník < > [email protected]> wrote: > >> >> >> On Wed, 17 Dec 2025 at 15:38, Paul "LeoNerd" Evans < >> [email protected]> wrote: >> >> > I always though that abstract has same usefulness as Java's final - hardly >> to be distinguished from zero. >> > > Final classes can be interesting. In some languages, you no longer have to > use a vtable to lookup methods, meaning you get a nice performance boost. > It's also useful when you have extremely sensitive classes (e.g., > something security related) which you don't want people to change without > careful consideration. It also makes it impossible to violate Liskov :) > imho this should not be property of the class but of an instance (or data contact). I have no problem with restrictions like (hypothetical): - new final Class ... - foo (final Class b) to require exact instance - as well as a hint to compiler that it can do compile time vtable mapping. > > I wouldn't reach for final classes as a first solution, but they're not > without merit. It's just that the use cases are somewhat restricted (though > our inability to enforce Liskov might be an argument). > > For abstract classes, they have uses, too, such as being the base class > for a factory and ensuring that every factory class has the required > interface. They do have one notable fragility, though. If you add a new > abstract method, all subclasses are immediately broken until they can be > updated. Maybe not so bad for closed source work, but bad for open source. > I get this reasons and all of them are still valid. Though I don't think there is any reason to use word abstract apart of fact saying "I'm not implementing method" ... that is still something compiler can easily guess - it knows that method is declared but not implemented in class. Also interfaces and abstract is imho better implemented via role mechanism - for me (you know how my brain works) this sounds like "abstract class = role with subset of features". > > Best, > Ovid > -- > https://curtispoe.org/ >