Lazare,

>> This won't make it easy passing a variable as reference.
>
> Type casting combined with passing by reference is problematic in many ways.

No it's not.  The core functionality does it quite fine, and it uses
typed parameters...

> Just an example:
>
> fuction foo( string & $buffer) { ... }
> foo( $my_buffer );
>
> Here, $my_buffer has just been declared, so it is null. Should this be an
> error? I don't know! So, I think that that passing by reference should not
> be (immediately) supported.

This one one where my wants are superseded by existing functionality.
The current implementation has a definite answer to that.  And the
answer is that no, no notice is raised.  Plenty of people are using it
to that effect right now.  Check out this abomination:
http://stackoverflow.com/questions/9636052/is-there-a-way-to-pass-an-undeclared-variable-to-a-function-without-notice/9636395#9636395

However, it's also quite useful.  Look at your code base.  Whenever
you call preg_match with the third parameter, do you *always*
initialize the $match parameter?  And do you *always* make sure it's
an array?  The chances are very likely (based on a lot of the code
I've seen), no.

This functionality is very pervasive to the core, and we shouldn't go
changing it now (even implementing user-land pass-by-reference).  Not
supporting references is one thing, but changing the semantics of it
is a completely different talk...

Anthony

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to