If this patch doesn't break anything, and it doesn't give us any
difficulties with ZE2 or major design issues, I'm +1.
- Stig
On Tue, 2002-05-28 at 21:12, Jason T. Greene wrote:
> Due to this patch being sent during the msession discussion, it has not
> been noticed, so I am resending.
>
>
> -Jason
> ----
>
> From: Jason Greene <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
> Subject: [PHP-DEV] [PATCH] Allow constants / expressions to be passed by reference
> Date: 25 May 2002 02:18:52 -0500
>
> Problem
> -------
>
> There are some scenarios where a function requires the ability to modify
> parameters that may also be optional. Optional parameters work well,
> except in the scenario where all of the pass by reference parameters can
> be optional. ex the socket_select() function. Since select is
> argument-result, all three arrays that are taken as input must be passed
> by reference, yet any can be excluded. So for example if you were
> calling socket_select with a read socket array, a write socket array,
> yet no exception array (quite common), you are currently forced to do
> something like the following:
>
> $wfds = array($sock1, $sock2);
> $rfds = array($sock3, $sock4);
> $null = NULL;
>
> socket_select($rfds, $wfds, $null);
>
>
> I have ran into this problem before several times while developing in
> user space. (Especially when passing around semi-complex data
> structures)
>
> Proposed Solution
> ------------------
>
> Allow all expressions to be passed by reference. This will allow
> something like the following
>
> function normalize(&$element_tree, &$node_mapping, $max_depth){
> //Code
> }
>
> normalize($my_tree, NULL, 25000);
>
>
> Patch
> ------
>
> I have attached a patch against ZE2 that accomplishes this.
>
>
> Thanks,
> -Jason
>
>
>
>
>
> ----
>
> Index: zend_compile.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_compile.c,v
> retrieving revision 1.285
> diff -u -r1.285 zend_compile.c
> --- zend_compile.c 23 Apr 2002 18:06:53 -0000 1.285
> +++ zend_compile.c 25 May 2002 06:45:21 -0000
> @@ -1271,7 +1271,7 @@
> op = ZEND_SEND_REF;
> break;
> default:
> - zend_error(E_COMPILE_ERROR, "Only variables can be
>passed by reference");
> + op = ZEND_SEND_VAR;
> break;
> }
> }
> Index: zend_execute.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_execute.c,v
> retrieving revision 1.341
> diff -u -r1.341 zend_execute.c
> --- zend_execute.c 8 May 2002 18:43:19 -0000 1.341
> +++ zend_execute.c 25 May 2002 06:45:25 -0000
> @@ -2292,10 +2292,6 @@
> NEXT_OPCODE();
> }
> case ZEND_SEND_VAL:
> - if (EX(opline)->extended_value==ZEND_DO_FCALL_BY_NAME
> - &&
>ARG_SHOULD_BE_SENT_BY_REF(EX(opline)->op2.u.opline_num, EX(fbc),
>EX(fbc)->common.arg_types)) {
> - zend_error(E_ERROR, "Cannot pass
>parameter %d by reference", EX(opline)->op2.u.opline_num);
> - }
> {
> zval *valptr;
> zval *value;
> @@ -2329,7 +2325,8 @@
>
>zend_ptr_stack_push(&EG(argument_stack), varptr);
> NEXT_OPCODE();
> }
> - zend_error(E_ERROR, "Only variables can be
>passed by reference");
> + /* Should only occur with an uninitialized
>variable */
> + goto send_by_var;
> }
> NEXT_OPCODE();
> case ZEND_SEND_VAR:
>
> ----
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> ----
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php