Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
2013/3/7 Stas Malyshev smalys...@sugarcrm.com Hi! RFC updated. Any other comments about this RFC? Could you provide a use case for this - which practical value this has? It also still contains factually incorrect claim that unset() is a function and that there's some inconsistency in the fact that it does not return value. Also, it is not clear what false returned from unset() actually means - did it fail to unset the value (i.e., it is still set) Shouldn't this fail a little bit more obvious (- loud)? And how is this even possible? or there was nothing to unset (i.e., it is still not set)? So I guess this is the only useful behaviour. However, I have no idea, what this information should tell me. If I call unset() then I want to ensure, that the variable is not set anymore, but for what reason I should need to know, whether it was set before, or not? Regards, Sebastian -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- github.com/KingCrunch
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Hi! Shouldn't this fail a little bit more obvious (- loud)? And how is this even possible? Well, for example - __unset is required to do X before unsetting variable but X fails for one reason or another and the logic dictates that you can not unset unless X is done (for a real life example, try exiting an app like word processor with content unsaved and when it asks you to save/discard/cancel, click on cancel. Bingo - unset interrupted :). or there was nothing to unset (i.e., it is still not set)? So I guess this is the only useful behaviour. However, I have no idea, This behavior is already covered by isset, why duplicate it? If - and I have no idea why - you cared if the variable was set or not, why not just do isset? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On 7 March 2013 09:45, Sebastian Krebs krebs@gmail.com wrote: So I guess this is the only useful behaviour. However, I have no idea, what this information should tell me. If I call unset() then I want to ensure, that the variable is not set anymore, but for what reason I should need to know, whether it was set before, or not? I think I actually had an use case with proxies, where I wanted to know if a property was set or not. That's useful to reset the proxy state (basically to intercept property access) and differentiate null properties vs non existing properties: class Blah extends Blubb { protected $prop; public function __construct() { unset($this-prop); } public function init() { $this-prop = 'stuff'; } public function reset() { return unset($this-prop); } // we now know if `init` was called } This *could* be useful if I want to keep track of the state of a proxy, but it's just an additional property to keep track of manually on the other side. The additional property is also more explicit and easier to track. Yes, it needs a better use case. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Am 7.3.2013 um 00:32 schrieb Stas Malyshev smalys...@sugarcrm.com: Hi! RFC updated. Any other comments about this RFC? Could you provide a use case for this - which practical value this has? It also still contains factually incorrect claim that unset() is a function and that there's some inconsistency in the fact that it does not return value. Also, it is not clear what false returned from unset() actually means - did it fail to unset the value (i.e., it is still set) or there was nothing to unset (i.e., it is still not set)? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Hi! The main practical value is in the __unset magic method. You can now communicate through the proper way of a language construct with an __unset method. (success or failure) I've added a code example to the RFC. Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Hi! The main practical value is in the __unset magic method. You can now communicate through the proper way of a language construct with an __unset method. (success or failure) I'm not sure how useful is that based on your example - unset could throw the exception as well... And the whole case seems still unclear - what is false supposed to mean in general case? Property didn't exist? Property can not be unset due to special semantics? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Thu, Mar 7, 2013 at 7:10 AM, Bob Weinand bobw...@hotmail.com wrote: Am 7.3.2013 um 00:32 schrieb Stas Malyshev smalys...@sugarcrm.com: Hi! RFC updated. Any other comments about this RFC? Could you provide a use case for this - which practical value this has? It also still contains factually incorrect claim that unset() is a function and that there's some inconsistency in the fact that it does not return value. Also, it is not clear what false returned from unset() actually means - did it fail to unset the value (i.e., it is still set) or there was nothing to unset (i.e., it is still not set)? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Hi! The main practical value is in the __unset magic method. You can now communicate through the proper way of a language construct with an __unset method. (success or failure) The practical value in __unset is that you can unset an unavailable property. The goal of unset has never been to communicate anything. It simply destroys a variable. Furthermore, if you're looking to identify, based on your examples, if you need to do cleanup work if a variable is set, your application should check to see if that value is set. Unset is part of the cleanup work itself. It would be nice to see actual use cases in an application rather than examples showing that your very specific use cases would work with this change. I've yet to see any value added by this RFC. I've added a code example to the RFC. Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On 3/6/13 4:10 PM, Bob Weinand wrote: https://wiki.php.net/rfc/unset_bool What's the return value of unset($setValue, $undefined) ? Steve Clay -- http://www.mrclay.org/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
false. It's like unset($setValue) unset($undefined). I've clarified this in the RFC; thank you. Bob Weinand Am 06.03.2013 um 22:24 schrieb Steve Clay st...@mrclay.org: On 3/6/13 4:10 PM, Bob Weinand wrote: https://wiki.php.net/rfc/unset_bool What's the return value of unset($setValue, $undefined) ? Steve Clay -- http://www.mrclay.org/ -- 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] unset(): return bool if the variable has existed
Hello, On Wed, Mar 6, 2013 at 11:31 PM, Bob Weinand bobw...@hotmail.com wrote: false. It's like unset($setValue) unset($undefined). I've clarified this in the RFC; thank you. Bob Weinand Am 06.03.2013 um 22:24 schrieb Steve Clay st...@mrclay.org: On 3/6/13 4:10 PM, Bob Weinand wrote: https://wiki.php.net/rfc/unset_bool What's the return value of unset($setValue, $undefined) ? Steve Clay -- http://www.mrclay.org/ Would it make more sense to return an array with keys the name of the variables that were unset and the result for each of them? This way one could better handle 'false' being returned. I'm not sure if it's possible or not, I didn't had the time to check out the patch. Thanks Florin Patan https://github.com/dlsniper -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Florin Would it make more sense to return an array with keys the name of the variables that were unset and the result for each of them? This way one could better handle 'false' being returned. I'm not sure if it's possible or not, I didn't had the time to check out the patch. If you need that much granularity, just call unset() individually for each one... Anthony
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 10:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php unset is not a function, but a language construct, and there is at least one similar construct which doesn't return anything (eg. not returning NULL, but syntax error when used in a return context): echo -- Ferenc Kovács @Tyr43l - http://tyrael.hu
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 4:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool I'm not a fan of this change, but if it's going to be discussed, the RFC should include baseline and RFC change benchmarks. Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 10:38 PM, Ferenc Kovacs tyr...@gmail.com wrote: On Wed, Mar 6, 2013 at 10:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php unset is not a function, but a language construct, and there is at least one similar construct which doesn't return anything (eg. not returning NULL, but syntax error when used in a return context): echo referring to This removes also an inconsistency: the function's return value is void, states the docs. It is until now the only function which has no return value. especially. -- Ferenc Kovács @Tyr43l - http://tyrael.hu
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 4:40 PM, Ferenc Kovacs tyr...@gmail.com wrote: On Wed, Mar 6, 2013 at 10:38 PM, Ferenc Kovacs tyr...@gmail.com wrote: On Wed, Mar 6, 2013 at 10:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php unset is not a function, but a language construct, and there is at least one similar construct which doesn't return anything (eg. not returning NULL, but syntax error when used in a return context): echo referring to This removes also an inconsistency: the function's return value is void, states the docs. It is until now the only function which has no return value. especially. Agreed. The RFC needs to be updated as to not mislead readers. -- Ferenc Kovács @Tyr43l - http://tyrael.hu
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Am 06.03.2013 um 22:47 schrieb Ferenc Kovacs tyr...@gmail.com: On Wed, Mar 6, 2013 at 10:41 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:38 schrieb Ferenc Kovacs tyr...@gmail.com: On Wed, Mar 6, 2013 at 10:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php unset is not a function, but a language construct, and there is at least one similar construct which doesn't return anything (eg. not returning NULL, but syntax error when used in a return context): echo -- Ferenc Kovács @Tyr43l - http://tyrael.hu Echo doesn't behave as a function as it doesn't need parenthesis etc. (and has an equivalent which can be used as alternative: print) I'd consider unset as a function in form of a language construct. Bob Weinand I'm not sure that we should change our terminology based on whether or not a language construct requires the parenthesis or not. there are other differences in behavior, for example $foo = print;$foo(bar); won't work even thought that print(bar); look likes as a function call. -- Ferenc Kovács @Tyr43l - http://tyrael.hu Ok; I think it's better not to argue about this... Bob Weinand
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 10:49 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:47 schrieb Ferenc Kovacs tyr...@gmail.com: On Wed, Mar 6, 2013 at 10:41 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:38 schrieb Ferenc Kovacs tyr...@gmail.com: On Wed, Mar 6, 2013 at 10:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php unset is not a function, but a language construct, and there is at least one similar construct which doesn't return anything (eg. not returning NULL, but syntax error when used in a return context): echo -- Ferenc Kovács @Tyr43l - http://tyrael.hu Echo doesn't behave as a function as it doesn't need parenthesis etc. (and has an equivalent which can be used as alternative: print) I'd consider unset as a function in form of a language construct. Bob Weinand I'm not sure that we should change our terminology based on whether or not a language construct requires the parenthesis or not. there are other differences in behavior, for example $foo = print;$foo(bar); won't work even thought that print(bar); look likes as a function call. -- Ferenc Kovács @Tyr43l - http://tyrael.hu Ok; I think it's better not to argue about this... Bob Weinand I'm glad that we sorted this out. -- Ferenc Kovács @Tyr43l - http://tyrael.hu
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Am 6.3.2013 um 22:50 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:44 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:39 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool I'm not a fan of this change, but if it's going to be discussed, the RFC should include baseline and RFC change benchmarks. Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php I don't see here a real need for a benchmark as it is mostly only returning SUCCESS or FAILURE instead of nothing. Nothing what would slow PHP down. Any change to a language construct which requires additional processing adds time. It may be in minute, but it's part of the discussion. Since this core change you're requesting comments for introduces a usecase which many will not find useful (probably most voting), it is your responsibility to convince this category of people that the tradeoff won't affect them that much. If you choose not to add benchmarking, I will guarantee a -1 from me. Bob Weinand I have tried the following: time ./sapi/cli/php -r 'while($i++ 1e7) { $a = true; unset($a); }' Unpatched: average of 5x executed: real0m4.935s user0m4.925s sys 0m0.008s Patched: average of 5x executed: real0m4.945s user0m4.938s sys 0m0.005s Yes, there is an increase of 0.15%. This is 1 nanosecond more than previous. Is this exact enough? Or do you need more precision? If yes, I'll put this into the RFC. Bob Weinand
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
On Wed, Mar 6, 2013 at 5:25 PM, Bob Weinand bobw...@hotmail.com wrote: Am 6.3.2013 um 22:50 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:44 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:39 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool I'm not a fan of this change, but if it's going to be discussed, the RFC should include baseline and RFC change benchmarks. Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php I don't see here a real need for a benchmark as it is mostly only returning SUCCESS or FAILURE instead of nothing. Nothing what would slow PHP down. Any change to a language construct which requires additional processing adds time. It may be in minute, but it's part of the discussion. Since this core change you're requesting comments for introduces a usecase which many will not find useful (probably most voting), it is your responsibility to convince this category of people that the tradeoff won't affect them that much. If you choose not to add benchmarking, I will guarantee a -1 from me. Bob Weinand I have tried the following: time ./sapi/cli/php -r 'while($i++ 1e7) { $a = true; unset($a); }' Unpatched: average of 5x executed: real 0m4.935s user 0m4.925s sys 0m0.008s Patched: average of 5x executed: real 0m4.945s user 0m4.938s sys 0m0.005s Yes, there is an increase of 0.15%. This is 1 nanosecond more than previous. Is this exact enough? Or do you need more precision? If yes, I'll put this into the RFC. Thank you. Please do add to the RFC Bob Weinand
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Am 6.3.2013 um 23:30 schrieb Will Fitch wfi...@meetme.com: On Wed, Mar 6, 2013 at 5:25 PM, Bob Weinand bobw...@hotmail.com wrote: Am 6.3.2013 um 22:50 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:44 PM, Bob Weinand bobw...@hotmail.com wrote: Am 06.03.2013 um 22:39 schrieb Will Fitch willfi...@php.net: On Wed, Mar 6, 2013 at 4:10 PM, Bob Weinand bobw...@hotmail.com wrote: Hi! As this seem to require a RFC, here is it: https://wiki.php.net/rfc/unset_bool I'm not a fan of this change, but if it's going to be discussed, the RFC should include baseline and RFC change benchmarks. Please feedback, Bob Weinand -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php I don't see here a real need for a benchmark as it is mostly only returning SUCCESS or FAILURE instead of nothing. Nothing what would slow PHP down. Any change to a language construct which requires additional processing adds time. It may be in minute, but it's part of the discussion. Since this core change you're requesting comments for introduces a usecase which many will not find useful (probably most voting), it is your responsibility to convince this category of people that the tradeoff won't affect them that much. If you choose not to add benchmarking, I will guarantee a -1 from me. Bob Weinand I have tried the following: time ./sapi/cli/php -r 'while($i++ 1e7) { $a = true; unset($a); }' Unpatched: average of 5x executed: real 0m4.935s user 0m4.925s sys 0m0.008s Patched: average of 5x executed: real 0m4.945s user 0m4.938s sys 0m0.005s Yes, there is an increase of 0.15%. This is 1 nanosecond more than previous. Is this exact enough? Or do you need more precision? If yes, I'll put this into the RFC. Thank you. Please do add to the RFC Bob Weinand RFC updated. Any other comments about this RFC? Bob Weinand
Re: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
Hi! RFC updated. Any other comments about this RFC? Could you provide a use case for this - which practical value this has? It also still contains factually incorrect claim that unset() is a function and that there's some inconsistency in the fact that it does not return value. Also, it is not clear what false returned from unset() actually means - did it fail to unset the value (i.e., it is still set) or there was nothing to unset (i.e., it is still not set)? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php