Re: [RFC] Static classes (Was Abstract final classes)

From: Date: Mon, 01 Dec 2014 15:32:53 +0000
Subject: Re: [RFC] Static classes (Was Abstract final classes)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-79342@lists.php.net to get a copy of this message
Hi! > On 1 Dec 2014, at 15:27, guilhermeblanco@gmail.com wrote: > > Hi Andrea, > > Thanks a lot for putting efforts thinking through this problem. > Indeed we have 3 problems that leads to "static classes". You detailed 2 of them. > The third is around encapsulation. I may want functions that are reused by other functions at > the namespace level, but that shouldn't be used outside of it. By purely supporting (1), you > still didn't address this issue. That would be easily addressed by having private static > functions inside of the static class. Hmm. Well, having functions not to be used outside of the namespace/file isn’t a problem unique to classes. That would be useful for people writing normal functions. Having something like static functions would be great. > So, as you walk through your options, didn't it feel wrong to you? Static classes are an > easy addiction to the language and would have a negligent performance impact, since it just adds 2 > conditions in zend_vm and zend_api. Yes, they’re a simple addition, but I still think they’re the wrong solution to the problem. We shouldn’t force people to use classes for simple collections of functions. People have wanted function autoloading for years. I say it’s high time we add that. Thanks! -- Andrea Faulds http://ajf.me/

« previous php.internals (#79342) next »