Annotation of embedaddon/php/Zend/RFCs/003.txt, revision 1.1.1.1

1.1       misho       1: Title:           Loose type requirements for functions
                      2: Version:         $Revision: 57685 $
                      3: Status:          draft
                      4: Maintainer:      Brian Moon <brianm@dealnews.com>
                      5: Created:         2001-09-17
                      6: Modified:        2001-09-17
                      7: 
                      8: 
                      9: 1. Background/Need
                     10: ==================
                     11: 
                     12: Many internal function of PHP will reject parameters because of their
                     13: type (the array and variable function come to mind).  For userland
                     14: this is not an easy task as there is no uniform way to do it.  An
                     15: addition to the engine for requiring loose types would allow
                     16: delevopers to know that the data passed to their functions is of the
                     17: correct type and reduce the need for duplicating the same code in
                     18: every function to check for the type of data.
                     19: 
                     20: 
                     21: 2. Overview
                     22: ===========
                     23: 
                     24: Loose typing mostly means evaluating the contents of the variable and
                     25: not the type of the variable itself.  The requirements for this would
                     26: and should work much like several of the is_* functions do now.
                     27: 
                     28: The typing of parameters would be optional and those not typed would
                     29: simply continue to be treated as they are now.
                     30: 
                     31: 3. Functionality
                     32: ================
                     33: 
                     34: 3.1. Allowed Types
                     35: ==================
                     36: 
                     37: Only loose types should be needed to ensure the data is usable by the
                     38: function.  Duplicating the functionallity of is_scalar, is_resource,
                     39: is_array and is_object should give developers all the information they
                     40: need to use a variable correctly.
                     41: 
                     42: 3.2. Syntax
                     43: ===========
                     44: 
                     45: The current function syntax should be expanded to allow typing of
                     46: variables inline in a C style.
                     47: 
                     48: function foo ($var){
                     49: }
                     50: 
                     51: could be changed to require an array such as:
                     52: 
                     53: function foo (array $var){
                     54: }
                     55: 
                     56: 3.3. Errors
                     57: ===========
                     58: 
                     59: Mis-matches in type should be reported as fatal errors and should halt
                     60: the execution of a script as that function can not be run and code
                     61: following could not reliably run.
                     62: 
                     63: 
                     64: 4. Compatibility Notes
                     65: ======================
                     66: 
                     67: Old code that does not take advantage of this will run without
                     68: modifications.
                     69: 
                     70: 
                     71: 
                     72: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>