rfc:simple-annotations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:simple-annotations [2016/05/13 11:15] mindplayrfc:simple-annotations [2016/05/14 19:38] mindplay
Line 1: Line 1:
 ====== PHP RFC: Simple Annotations ====== ====== PHP RFC: Simple Annotations ======
  
-  * Version: 0.1+  * Version: 0.3
   * Date: 2016-05-13   * Date: 2016-05-13
   * Author: Rasmus Schultz, rasmus@mindplay.dk   * Author: Rasmus Schultz, rasmus@mindplay.dk
Line 83: Line 83:
 ==== Annotations are Context-free ==== ==== Annotations are Context-free ====
  
-By design, there is no access to variables in the parent class, file or global scope, no ''self'' or ''static'' or ''$this''.+By design, annotations expressions are evaluated individually in an empty scope - which means there is no access to variables in the parent class, file, local or global scope, e.g. no ''$this''''self'' or ''static''.
  
 Annotations work consistently regardless of which source element they are applied to, and may be evaluated without first creating an object instance. Annotations work consistently regardless of which source element they are applied to, and may be evaluated without first creating an object instance.
- 
-You can think of an annotation ''<< expression() >>'' as executing in an anonymous function scope, e.g.: 
- 
-    function () { return expression(); } 
  
 Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function, a ''callable'', or an anonymous class, to provide context via dependency injection. Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function, a ''callable'', or an anonymous class, to provide context via dependency injection.
Line 147: Line 143:
 ===== Future Scope ===== ===== Future Scope =====
  
-TODO file-level annotations? others?+A future RFC might include certain system annotations containing directives for the language interpreter itself. This might include a memoization-annotation that instructs the interpreter to memoize a function result on first call, such as is [[https://docs.hhvm.com/hack/attributes/special|supported by Hack]].
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/simple-annotations.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1