rfc:changes_to_include_and_require
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:changes_to_include_and_require [2012/03/06 16:01] – created michaelmorris | rfc:changes_to_include_and_require [2012/03/12 20:04] – Questions section added (feel free to expand) lynch | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Request for Comments: Additional | + | ====== Request for Comments: Additional |
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2012-03-06 | * Date: 2012-03-06 | ||
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Proposed are a pair of changes to the file inclusion process, and the four language statements that process those includes - include, include_once, | + | Change |
+ | require( ' | ||
- | ===== Tagless Files ===== | + | Currently files are always imported to the root namespace. |
- | + | ||
- | A common beginner gotcha occurs the first time they attempt to use sessions or the header function. Whitespace outside the php tags is sent to the browser, and the first time this occurs its too late to start a session or make changes to the file header, so a warning is output. | + | |
- | + | ||
- | This could be avoided if a PHP file could be written and accepted without an opening <?php tag (the closing tag can be omitted without affecting the parser - whether it should be is up for debate). | + | |
- | + | ||
- | If ' | + | |
- | + | ||
- | Framework designers can more strongly enforce code separation. For example, if a coder attempts to jump to html output in what the framework expects to be a database interface class - which shouldn' | + | |
- | + | ||
- | ===Questions=== | + | |
- | Is it worth the time to enforce the whole file be tag less? I would imagine on the implementation side doing what is discussed above would be as simple as appending "<? | + | |
- | + | ||
- | Would the engine run faster if it could parse the file without worrying about the <?php ?> tokens at all? Would the pickup be worth the time? | + | |
- | + | ||
- | ===Problems=== | + | |
- | The largest problem is with IDE's. There is no current convention to warn them that the file is pure PHP. However, I think this can be mitigated by adopting an extension for php include files -- *.pif, *.iphp are two possibilities. | + | |
- | + | ||
- | An addendum to this problem is the possibility of having PHP parse the file differently dependent on the extension. | + | |
- | + | ||
- | + | ||
- | ===== Defining Namespace on Inclusion ===== | + | |
- | + | ||
- | Currently files are always imported to the root namespace. | + | |
- | namespace is specified then the file is imported to that namespace. If the file has a namespace definition that namespace becomes a sub-namespace when imported. | + | |
The lesser use of this change is to allow php template files to not have to start with a namespace declaration. Since these files are meant to be used by designers the namespace declaration, | The lesser use of this change is to allow php template files to not have to start with a namespace declaration. Since these files are meant to be used by designers the namespace declaration, | ||
Line 53: | Line 30: | ||
This provides a powerful layer of flexibility for frameworks. | This provides a powerful layer of flexibility for frameworks. | ||
+ | |||
+ | ===== Questions ===== | ||
+ | |||
+ | 1) | ||
+ | Is it not possible that the library being pulled contains references to itself in the original namespace, rather than the new sub-namespace the require/ | ||
+ | |||
+ | Or do you anticipate that all such references would be converted? | ||
+ | |||
+ | What if, somehow, the library composes the reference from $data rather than hard-coded? (Which might be kind of crazy, but you know those PHP guys...) | ||
+ | |||
+ | 2) Add more questions. | ||
===== Changelog ===== | ===== Changelog ===== | ||
2012-03-06 - Initial proposal. | 2012-03-06 - Initial proposal. | ||
+ | 2012-03-08 - Dropped one of the pair after negative reception on the list to concentrate on the second. |
rfc/changes_to_include_and_require.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1