Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Derick Rethans wrote: On Wed, 21 May 2008, Steph Fox wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: http://wiki.php.net/rfc/calltimebyref I don't think we should get rid of it, or add a notice/message/whatever. Because this: http://pastebin.com/d6e055957 This pastebin expired, but is the same as: http://pastebin.com/f1d8c08e8 and: http://bugs.php.net/bug.php?id=45126 could not be done without call time pass by ref right now. So unless that's fixed, we shouldn't deprecate it. regards, Derick - Mark -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
On Wed, 21 May 2008, Steph Fox wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: http://wiki.php.net/rfc/calltimebyref I don't think we should get rid of it, or add a notice/message/whatever. Because this: http://pastebin.com/d6e055957 could not be done without call time pass by ref right now. So unless that's fixed, we shouldn't deprecate it. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hello Steph, I am all for it: Making sure PHP's 5.3 default is OFF and issueing a warning when turning on starting with 5.3. marcus Wednesday, May 21, 2008, 3:13:04 PM, you wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: http://wiki.php.net/rfc/calltimebyref - Steph Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
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
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hi! 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 There's no such thing as passing reference or passing value. Same thing is always passed - zval. Only thing changing is does the function intend to modify it. That depends on function semantics. 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. Believe me, you not, unless you want to turn PHP into C. -- 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
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
On Wed, 21 May 2008, Steph Fox wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: http://wiki.php.net/rfc/calltimebyref I'm all for it. regards, Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
On Wed, May 21, 2008 at 10:46 PM, LEW21 [EMAIL PROTECTED] wrote: Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null); what stops you from declaring: function someFunc($param = null) { } it works just fine Deleting it isn't a good idea, it should become a normal (not deprecated) language feature. -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hi, There is a use case for the function allowing *explicitly* call-time pass by reference, because the function works both ways in subtly different ways. I have some libraries where I had to have variations of the functions like AbcByRefr() and Abc(), because of this inflexibility. 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 --- function bar($a) {} // forbids pass by reference foo($a); // legal, pass as 'copy' foo( $a); // illegal, error --- function baz(? $a) {} // acknowledges that it functions properly and accepts both ways foo($a); // legal, pass as 'copy' foo( $a); // legal, pass as reference --- Regards, Stan Vassilev On Wed, May 21, 2008 at 10:46 PM, LEW21 [EMAIL PROTECTED] wrote: Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null); what stops you from declaring: function someFunc($param = null) { } it works just fine Deleting it isn't a good idea, it should become a normal (not deprecated) language feature. -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- 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
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
2008/5/22, Alexey Zakhlestin [EMAIL PROTECTED]: On Wed, May 21, 2008 at 10:46 PM, LEW21 [EMAIL PROTECTED] wrote: Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null); what stops you from declaring: function someFunc($param = null) { } it works just fine And what if this param isn't the last param of this function, and next params are required? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
On Thu, May 22, 2008 at 2:51 PM, LEW21 [EMAIL PROTECTED] wrote: 2008/5/22, Alexey Zakhlestin [EMAIL PROTECTED]: On Wed, May 21, 2008 at 10:46 PM, LEW21 [EMAIL PROTECTED] wrote: Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null); what stops you from declaring: function someFunc($param = null) { } it works just fine And what if this param isn't the last param of this function, and next params are required? Then I would say that is a bad design -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hi, Actually PHP ignores default values on parameters followed by required ones. You can't fetch the default value even via Reflection. This is easily detected at compile time so I wonder why the compiler doesn't warn. Regards, Stan Vassilev what stops you from declaring: function someFunc($param = null) { } it works just fine And what if this param isn't the last param of this function, and next params are required? Then I would say that is a bad design -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ -- 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
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hi Stan, There is a use case for the function allowing *explicitly* call-time pass by reference, because the function works both ways in subtly different ways. This RFC isn't about whether or not this behaviour should be deprecated. It simply recommends that a warning be thrown by default in PHP 5.3 so that people will know to fix their code. The rationale for this is that there is ALWAYS a warning thrown in PHP 6, with no possibility to avoid that warning. It is also still marked deprecated in PHP 6, i.e. there is presumably a firm intention to remove the possibility for call-time pass-by-ref altogether. call_time_pass_by_reference behaviour has been deprecated for 8 years plus - since before the PHP 4.0 release. If you're writing code that relies on that behaviour, either you don't care about the warning or you've never seen it. I suspect rather a lot of PHP users have never seen it, because by default that warning isn't thrown at all. If you want to argue that there should be no warning by default, fine. But please try to stay on-topic. Thanks, - Steph -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Hello Steph, Is it me, or the wiki post talks about param and return by ref? Return by ref is not related to call-time pass by ref, is it? Anyway, my opinion is clear on that one: shoot that dead cow. It's been deprecated for years, and you should declare your function prototypes with the param by ref anyway if you need it. Regards, Olivier On Wed, May 21, 2008 at 9:13 AM, Steph Fox [EMAIL PROTECTED] wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Is it me, or the wiki post talks about param and return by ref? Return by ref is not related to call-time pass by ref, is it? See zend_compile.c. Anyway, my opinion is clear on that one: shoot that dead cow. It's been deprecated for years, and you should declare your function prototypes with the param by ref anyway if you need it. Did you bother to read the proposal or did you just hit send? What exactly do you think the RFC is about? - Steph -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
For anyone else who doesn't read to the end... Anyway, my opinion is clear on that one: shoot that dead cow. It's been deprecated for years, and you should declare your function prototypes with the param by ref anyway if you need it. All I'm asking is that we throw a warning by default in 5_3, because in PHP 6 there isn't even an option to switch that warning off. To be frank this shouldn't ever have needed to go to an RFC; the lack of warning is an obvious bug in PHP which should simply be fixed. - Steph -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Steph Fox wrote: I looked into it again (and found things I didn't know before). This one's bugging me enough that I braved the Wiki: http://wiki.php.net/rfc/calltimebyref It has: | Proposal | | Switch allow_call_time_pass_reference off by default in PHP_5_3 | branch. At present there is no warning when running PHP under default | settings, whereas in PHP 6 there will be a 'deprecated' warning given | and no means of turning it off. We will be switching it on for our extension requirements. It would be nice if it can be turned on in the [extension] section and the PHP parser would enabled it per the extension's API call only and not others. -- Hector Santos -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RFC: allow_call_pass_by_reference
Sometimes call time pass by reference is useful, for example when you want to make it possible to omit an param (normally passed by reference) by setting null. With no call time pass by reference, programmers are required to write: $null = null; foo($null); Deleting it isn't a good idea, it should become a normal (not deprecated) language feature. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php