Re: [RFC] New core autoloading mechanism with support for function autoloading
| From: | Deleu | Date: | Mon, 10 Apr 2023 15:36:14 +0000 |
| Subject: | Re: [RFC] New core autoloading mechanism with support for function autoloading | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119863@lists.php.net to get a copy of this message | ||
On Mon, Apr 10, 2023 at 10:01 AM Ondřej Mirtes <ondrej@mirtes.cz> wrote:
> I don’t like the proposed function names:
>
> autoload_register_class to me reads like “register this class for
> autoloading”. If I observe the intended meaning correctly, it should be
> called “register_class_autoloader”.
>
> Same for autoload_register_function - better name would be
> “register_function_autoloader”.
>
> Other functions should be renamed accordingly. Function names should read
> like a sentence, like a command.
>
> On Mon 10. 4. 2023 at 14:17, G. P. B. <george.banyard@gmail.com> wrote:
>
> > Hello Internals,
> >
> > Dan and I would like to propose a new core autoloading mechanism that
> fixes
> > some minor design issues with the current class autoloading mechanism and
> > introduce a brand-new function autoloading mechanism:
> > https://wiki.php.net/rfc/core-autoloading
> >
> > The existing SPL autoloading functions would become aliases to the new
> Core
> > ones and will continue to work without any migrations needing to be
> > performed.
> >
> > Hope to hear your opinions about this!
> >
> > Best regards,
> >
> > George P. Banyard
> >
> --
>
> Ondřej Mirtes
>
I'm guessing autoload_* was chosen because PHP internal functions are
bundled by prefix and register_* would not make a good bundle name for the
autoloading functionality.
What helps me when thinking about PHP internals function is to assume the
first word is a class, such as:
$autoload = new Autoload();
And then everything after the first underscore is a method name, such as
$autoload->register_class();. What I can recommend in this case is to make
them autoload_register_class_loader() and
autload_unregister_class_loader(), but prefixing everything with register_*
would be essentially $register = new Register();, but register what?
--
Marco Deleu