Re: [RFC] Abstract final classes
| From: | Rowan Collins | Date: | Thu, 27 Nov 2014 12:43:13 +0000 |
| Subject: | Re: [RFC] Abstract final classes | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79226@lists.php.net to get a copy of this message | ||
Lazare Inepologlou wrote on 27/11/2014 10:35:
2014-11-27 4:47 GMT+01:00 guilhermeblanco@gmail.com < guilhermeblanco@gmail.com>:This has always been my feeling. To me, "abstract" means "must be extended", and "final" means "can't be extended", so combining the two seems like a self-contradiction. The fact that abstract classes allow static methods to be called without sub-classing always seems a bit odd to me - it's as though only the constructor is really abstract, not the whole class. A "static" class, however, whether "final" or not, is definitely something I've wanted. Regards, -- Rowan Collins [IMSoP]Hi, I worked on an implementation of a somehow controversial concept that exists in hack and C#: abstract final classes. https://wiki.php.net/rfc/abstract_final_class My motivation is to further expand class support to add modifiers (PPP - public, protected, private). I added this change to initially segregate grammar rules. It was an easy feature without extensive complexity and covers some use-cases."Abstract final" is a strange way to name it. What you want is a "static" class: * The fact that one cannot initialise an abstract class is only a side effect. Abstract classes are meant to be used for inheritance. * Abstract static methods are not possible (one more reason why abstract is a bad name). * A "static" class does not have to be final, given the fact that PHP is one of the few languages that offer a robust Late Static Binding.