rfc:core-autoloading
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:core-autoloading [2023/04/03 14:45] – Share the glory, share the blame. danack | rfc:core-autoloading [2023/04/23 14:24] (current) – danack | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Date: 2023-04-03 | * Date: 2023-04-03 | ||
* Author: George Peter Banyard, < | * Author: George Peter Banyard, < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.3 | * Target Version: PHP 8.3 | ||
* Implementation: | * Implementation: | ||
Line 16: | Line 16: | ||
The need for such a feature seems very clear as users will create " | The need for such a feature seems very clear as users will create " | ||
- | A previous [[draft RFC for function autoloading|https:// | + | A previous [[https:// |
This RFC has avoided that performance problem. | This RFC has avoided that performance problem. | ||
Line 103: | Line 103: | ||
If a function already exists with the global namespace name, that will be used, otherwise the function autoloader mechanism will call the registered function autoloaders once with the global function name. | If a function already exists with the global namespace name, that will be used, otherwise the function autoloader mechanism will call the registered function autoloaders once with the global function name. | ||
- | After a function autoload | + | After a function in a namespace is resolved (i.e. a function is located in the current namespace either because it already exists, or a function autoload |
This is possibly easier to understand through code: | This is possibly easier to understand through code: | ||
Line 249: | Line 249: | ||
Passing < | Passing < | ||
+ | |||
+ | The current RFC as proposed has a large BC break for the code: | ||
+ | |||
+ | <PHP> | ||
+ | |||
+ | namespace foo; | ||
+ | |||
+ | var_dump(function_exists(' | ||
+ | var_dump(strlen(' | ||
+ | var_dump(function_exists(' | ||
+ | |||
+ | if (true) { | ||
+ | function strlen($x) { return 42; } | ||
+ | var_dump(function_exists(' | ||
+ | } | ||
+ | |||
+ | var_dump(strlen(' | ||
+ | |||
+ | </ | ||
+ | |||
+ | Which needs to be thought about. | ||
===== Proposed PHP Version ===== | ===== Proposed PHP Version ===== | ||
Line 283: | Line 304: | ||
==== Higher performance through maps ==== | ==== Higher performance through maps ==== | ||
- | There is an ongoing conversation, | + | There is an ongoing conversation, |
+ | |||
+ | However, a basic implementation of that RFC has been created and can be tried with the implementation of this RFC: https:// | ||
====== Deprecating the SPL autoloader functions ====== | ====== Deprecating the SPL autoloader functions ====== | ||
Line 394: | Line 417: | ||
For programs that do not have a function autoloader registered, there will be no autoloader to dispatch, so there will be almost no performance change. | For programs that do not have a function autoloader registered, there will be no autoloader to dispatch, so there will be almost no performance change. | ||
- | Whether or not a fuction | + | Whether or not a function |
As the code example shows, after a successful attempt to autoload a function in a namespace, or the global function fallback occurs, the function is ' | As the code example shows, after a successful attempt to autoload a function in a namespace, or the global function fallback occurs, the function is ' |
rfc/core-autoloading.1680533133.txt.gz · Last modified: 2023/04/03 14:45 by danack