Hi,

There are three purposes:

1) At call time, nothing significes what is the caller passing, the syntax is the same for passing reference or passing value, so it's prone to confusion. You're passing something which *may* or *may not* be modified if taken as a reference. Quick, is the variable taken by reference here somefunction($hi). A more clear version of the syntax is what I covered in my original email, where declaring function foo(& $foo) is a sort of contract that *forces* (with error) that the variable is passed by reference at call time, thus making the actions of the function explicit.

2) There's a broken symmetry here. While passing by reference is implicit at call time, at return time it's not. I need to both declare the function return by reference AND use "= & " to assign the results. Otherwise I get a copy. That's a problem I often have. There's no compiler error to warn me I did otherwise.

I'd rather all those be explicit( require pass/return by val, require pass/return by refr: "&", accepts both "&?"), and the strict cases throw errors when the contract is not met at both sides.

3) As I mentioned there are three use cases, of which we support two, which I covered in my original email.

The reason I said "in a perfect world" is because the current "hidden" pass by reference at call time will be incompatible with that scheme, so I doubt anyone would consider it.

Regards,
Stan Vassilev

Hi!

In a perfect world, here's how I'd do it, of course the actual syntax can be something else (this also improves the understanding of the code as it makes the intent explicit, versus implicit at call time, as it is now):

---

function foo(& $a) {} // allows only explicit pass by reference

foo($a); // illegal, error
foo(& $a); // legal, pass by reference

I'm not sure I understand what's the purpose of this. Passing by reference means that function may modify it's parameter. I see no reason why such function should be called with some special syntax, could you explain?
--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED]   http://www.zend.com/
(408)253-8829   MSN: [EMAIL PROTECTED]

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



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

Reply via email to