php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49249 Call-time pass-by-reference deprecated -> undeprecate
Submitted: 2009-08-14 05:20 UTC Modified: 2009-08-14 22:48 UTC
From: ile at dennisgiese dot de Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.3.0 OS: Win XP Sp3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ile at dennisgiese dot de
New email:
PHP Version: OS:

 

 [2009-08-14 05:20 UTC] ile at dennisgiese dot de
Description:
------------
Please undreprecate Call-Time pass-by-reference, since it is a fully supported and used way of programming style in almost EVERY serious and "big" language!

Reproduce code:
---------------
If you have any kind of class or stack of functions you surely want to keep lines of code as short as possible. on the other hand you surely don't want to "copy" your variables just to call a function...

example:

building an XML document, while using a (sub)function in order to create only sligthly different paths:

private function _prepareRequest()
 {
   //[some other code]
    $this->_StoreInterval("from",&$xmlwriter,$this->startdate);
    $this->_StoreInterval("to",&$xmlwriter,$this->enddate);
   //[some other code]
 }

private function _StoreInterval($kind,&$xmlwriter,$date)
 {
    $xmlwriter->startElement($kind);
    $xmlwriter->writeElement("day",date("d",$date));
    $xmlwriter->writeElement("month",date("m",$date));
    $xmlwriter->writeElement("year",date("Y",$date));
    $xmlwriter->writeElement("hour",date("H",$date));
    $xmlwriter->endElement();
 }

Expected result:
----------------
in 5.3.0 this still works, but got an warning because this is "deprecated"...

Actual result:
--------------
actually this should be working anyway, since i don't want to waste memory just to copy and paste back results from this subfunction. 

if this won't work it makes - to some extend - building functions useles.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-14 08:48 UTC] derick@php.net
You're using references for all the wrong reasons here as well. Please refer to the php-general list as to why.
 [2009-08-14 19:43 UTC] ile at dennisgiese dot de
maybe but think of php functions like array_walk! you can turn them off then as well... 

don't tell me what is wrong-reasoned or not. just look at what is wrong-reasoned from YOUR site. i just tool that simple example since it was the closest i had used. 

just telling me ONE single reason, WHY it should be turned off!

it is nonsense - and, as stated above - throws php back to stoneage since EVERY other "good" programming language i know, make use of call-time pass-by-reference. 

and i won't look up general lists for reasons "why" because there are no reasons why to turn that off.
 [2009-08-14 22:48 UTC] rasmus@php.net
There are actually really good technical reasons for turning them off and not allowing by-refs to functions that do not handle them properly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC