Re: [PHP-DEV] Deprecate and remove case-insensitive constants?

This is only part of a thread. view whole thread
  100558
September 13, 2017 13:15 derokorian@gmail.com (Ryan Pallas)
On Wed, Sep 13, 2017 at 2:59 AM, Tony Marston <TonyMarston@hotmail.com>
wrote:

> >> > You seem to forget that autoloading is an option, not a requirement. I > don't use autoloading in my 14 year old framework for several reasons: > - An autoloader did not exist when I created my framework. > - I built an alternative mechanism into my framework, so I don't need an > autoloader. > - I don't like the way autoloaders work - all my class names are in snake > case (lowercase with underscore separators) and the autoloader converts '_' > into '/' thus producing a file path which does not exist. >
I must be missing something, there is no autoloader shipped with PHP. You have to define your own and register it. You can choose to change _ into / within your autoloader, but that is entirely preference and not specifically part of autoloading. For example, here's my autoloader which does no such symbol replacement https://pastebin.com/rQRrXzCa
> > By convention I always use uppercase for constants which makes them > instantly recognisable in my code as all other names are either completely > lowercase or mixed case. Making constants case sensitive instead of > insensitive would not affect me. > > However, I would be totally against switching the rest of the language to > be case sensitive for the following reasons: > - It would be a huge BC break no little or no benefit. > - It would allow developers to shoot themselves in the foot by having > different functions with the same name but different mixtures of case, so > that foo(), Foo() FOO() and fOO() would be treated as different functions. > - if people move from keyboard input to speech recognition, then simply > speaking a name would not work - you would have to spell it out character > by character, and specify either upper or lowercase for each character. >
This is about deprecating the third parameter in define, so userland constants defined by this function cannot be case insensitive. As mentioned before by Christoph this is not an attempt to change case sensitivity for other identifiers (functions, classes, etc) even if it was brought up before. That is not his intention here, and we need to stick to the focus of this RFC.
> People who think that case sensitive software is cool are deluding > themselves. When I started working on mainframe computers (UNIVAC and IBM) > in the early 1970s everything was case-insensitive. This was only changed > by people who did not understand the ramifications of their choice. > > -- > Tony Marston > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
  100561
September 13, 2017 14:06 rowan.collins@gmail.com (Rowan Collins)
On 13 September 2017 14:15:43 BST, Ryan Pallas <derokorian@gmail.com> wrote:
>I must be missing something, there is no autoloader shipped with PHP.
Just to be pedantically correct, there actually is an implementation shipped, see http://php.net/spl_autoload It's even the default if you don't pass your own function to spl_autoload_register. Nonetheless, you are quite right that Tony's complaint is nonsensical, because he could implement whatever autoloader suited his directory structure, if he wanted to - even a case insensitive one. It is true that autoloading isn't mandatory, but it's also a complete straw man, because Sara already made the same point herself:
> I don't feel as though that's true of ... > projects where autoloaders > aren't used (not a small number).
Regards, -- Rowan Collins [IMSoP]
  100563
September 13, 2017 15:50 derokorian@gmail.com (Ryan Pallas)
On Wed, Sep 13, 2017 at 8:06 AM, Rowan Collins collins@gmail.com>
wrote:

> On 13 September 2017 14:15:43 BST, Ryan Pallas <derokorian@gmail.com> > wrote: > >I must be missing something, there is no autoloader shipped with PHP. > > Just to be pedantically correct, there actually is an implementation > shipped, see http://php.net/spl_autoload It's even the default if you > don't pass your own function to spl_autoload_register. >
Almost 2 decades in PHP, and still so much I don't know haha. I will point out though, that according to a comment [1] it does not replace the underscores with slashes as mentioned, and I see no where in the code [2] that it does either. [1] http://php.net/manual/en/function.spl-autoload.php#98762 [2] https://github.com/php/php-src/blob/master/ext/spl/php_spl.c#L306
> > Nonetheless, you are quite right that Tony's complaint is nonsensical, > because he could implement whatever autoloader suited his directory > structure, if he wanted to - even a case insensitive one. > > It is true that autoloading isn't mandatory, but it's also a complete > straw man, because Sara already made the same point herself: > > > I don't feel as though that's true of ... > > projects where autoloaders > > aren't used (not a small number). > > Regards, > > -- > Rowan Collins > [IMSoP] >
  100565
September 13, 2017 16:12 TonyMarston@hotmail.com ("Tony Marston")
"Ryan Pallas"  wrote in message 
news:CAObuZdtmhxQ285hwMc3x9TH2rj9D7Ty3vnhNPcBzdCePpch9YA@mail.gmail.com...
> >On Wed, Sep 13, 2017 at 2:59 AM, Tony Marston <TonyMarston@hotmail.com> >wrote: > >> >>> >> You seem to forget that autoloading is an option, not a requirement. I >> don't use autoloading in my 14 year old framework for several reasons: >> - An autoloader did not exist when I created my framework. >> - I built an alternative mechanism into my framework, so I don't need an >> autoloader. >> - I don't like the way autoloaders work - all my class names are in snake >> case (lowercase with underscore separators) and the autoloader converts >> '_' >> into '/' thus producing a file path which does not exist. >> > >I must be missing something, there is no autoloader shipped with PHP. You >have to define your own and register it. You can choose to change _ into / >within your autoloader, but that is entirely preference and not >specifically part of autoloading. For example, here's my autoloader which >does no such symbol replacement https://pastebin.com/rQRrXzCa > >
Then it must have been the project I was working on which used a combination of Codeigniter, Composer and PHPUnit. There was definitely something which translated a class name from "foo_bar_snafu" into "foo/bar/snafu". It's no wonder that I stopped using it. -- Tony Marston http://www.tonymarston.net http://www.radicore.org