Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: craig at clearbooks dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: +1 for this language construct it would be awesome Previous Comments: [2013-05-16 20:02:39] charlie at gorichanaz dot com Well, I maintain I would love to see this control structure implemented. I understand a non English speaker might not have the same level of understanding of the word "unless" as a native English speaker, but you can say the same of any other keyword in PHP or any other programming language written in English, and I fail to see how that is a valid argument against its inclusion. [2013-02-20 18:36:04] email at philsturgeon dot co dot uk It looks like this conversation dried up after the rather out-of-context confusion over unless somehow meaning "more". Can we move past that please, as it's a ridiculous non-issue. [2012-07-30 15:09:00] email at philsturgeon dot co dot uk Rasmus: toby was not suggesting that "uniqid" is the opposite of "iqid", he is saying that you can have "un" at the start of a function or keyword without it automatically flipping the meaning of the next few letters and confusing people - as you suggested in your comment yesterday. In neither situation does "un" switch the meaning of the following letters, so if it is ok for one function/keyword it should be ok for another, right? I don't want to argue, I just want to make sure people are clear. I would hate to see this conversation derailed by confusion or people loudly agreeing. [2012-07-30 15:00:31] ras...@php.net Now you are just being silly. "uniqid" is "unique id" from the latin root "uni" meaning one or singular. Makes perfect sense . It isn't "un" anything. [2012-07-30 13:19:47] mail at tobyinkster dot co dot uk FWIW, while Perl does allow unless (foo) { bar } else { baz } I've never seen it in the wild. I've only ever seen unless used without any trailing else conditions. (And although Perl syntax allows else following unless, it explicitly disallows elsif following unless.) I'd be perfectly happy for PHP to forbid both elseif and else after unless. > It also isn't a very common feature in other languages Latin had "nisi". Modern languages derived from Latin are all the poorer for having lost this concept. > It is an odd word that essentially means not-if even though > it logically should be equivalent to "more" as in the > opposite of "more" would be "less" and sticking "un" in > front of it suddenly completely changes the meaning entirely. By that logic, uniqid() should return the opposite of the iqid() function. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: charlie at gorichanaz dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: Well, I maintain I would love to see this control structure implemented. I understand a non English speaker might not have the same level of understanding of the word "unless" as a native English speaker, but you can say the same of any other keyword in PHP or any other programming language written in English, and I fail to see how that is a valid argument against its inclusion. Previous Comments: [2013-05-16 19:45:59] freshtuneage at gmail dot com Ha ha, PHP lusers. "We don't want this feature because it is too complicated for our training wheel-restricted users." What a bunch of simplistic dolts. When you're ready to move forward into the brave new world of the 1990's, let the rest of us know. [2013-02-20 18:36:04] email at philsturgeon dot co dot uk It looks like this conversation dried up after the rather out-of-context confusion over unless somehow meaning "more". Can we move past that please, as it's a ridiculous non-issue. [2012-07-30 15:09:00] email at philsturgeon dot co dot uk Rasmus: toby was not suggesting that "uniqid" is the opposite of "iqid", he is saying that you can have "un" at the start of a function or keyword without it automatically flipping the meaning of the next few letters and confusing people - as you suggested in your comment yesterday. In neither situation does "un" switch the meaning of the following letters, so if it is ok for one function/keyword it should be ok for another, right? I don't want to argue, I just want to make sure people are clear. I would hate to see this conversation derailed by confusion or people loudly agreeing. [2012-07-30 15:00:31] ras...@php.net Now you are just being silly. "uniqid" is "unique id" from the latin root "uni" meaning one or singular. Makes perfect sense . It isn't "un" anything. [2012-07-30 13:19:47] mail at tobyinkster dot co dot uk FWIW, while Perl does allow unless (foo) { bar } else { baz } I've never seen it in the wild. I've only ever seen unless used without any trailing else conditions. (And although Perl syntax allows else following unless, it explicitly disallows elsif following unless.) I'd be perfectly happy for PHP to forbid both elseif and else after unless. > It also isn't a very common feature in other languages Latin had "nisi". Modern languages derived from Latin are all the poorer for having lost this concept. > It is an odd word that essentially means not-if even though > it logically should be equivalent to "more" as in the > opposite of "more" would be "less" and sticking "un" in > front of it suddenly completely changes the meaning entirely. By that logic, uniqid() should return the opposite of the iqid() function. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: freshtuneage at gmail dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: Ha ha, PHP lusers. "We don't want this feature because it is too complicated for our training wheel-restricted users." What a bunch of simplistic dolts. When you're ready to move forward into the brave new world of the 1990's, let the rest of us know. Previous Comments: [2013-02-20 18:36:04] email at philsturgeon dot co dot uk It looks like this conversation dried up after the rather out-of-context confusion over unless somehow meaning "more". Can we move past that please, as it's a ridiculous non-issue. [2012-07-30 15:09:00] email at philsturgeon dot co dot uk Rasmus: toby was not suggesting that "uniqid" is the opposite of "iqid", he is saying that you can have "un" at the start of a function or keyword without it automatically flipping the meaning of the next few letters and confusing people - as you suggested in your comment yesterday. In neither situation does "un" switch the meaning of the following letters, so if it is ok for one function/keyword it should be ok for another, right? I don't want to argue, I just want to make sure people are clear. I would hate to see this conversation derailed by confusion or people loudly agreeing. [2012-07-30 15:00:31] ras...@php.net Now you are just being silly. "uniqid" is "unique id" from the latin root "uni" meaning one or singular. Makes perfect sense . It isn't "un" anything. [2012-07-30 13:19:47] mail at tobyinkster dot co dot uk FWIW, while Perl does allow unless (foo) { bar } else { baz } I've never seen it in the wild. I've only ever seen unless used without any trailing else conditions. (And although Perl syntax allows else following unless, it explicitly disallows elsif following unless.) I'd be perfectly happy for PHP to forbid both elseif and else after unless. > It also isn't a very common feature in other languages Latin had "nisi". Modern languages derived from Latin are all the poorer for having lost this concept. > It is an odd word that essentially means not-if even though > it logically should be equivalent to "more" as in the > opposite of "more" would be "less" and sticking "un" in > front of it suddenly completely changes the meaning entirely. By that logic, uniqid() should return the opposite of the iqid() function. [2012-07-29 21:42:28] email at philsturgeon dot co dot uk In regards to double negatives, I agree. If I see a developer do this unless a != 7 then I would block their PR and instantly go and have a talk with them about writing sane code. As for else it really shouldn't be used that much but it should be possible. unless (foo === 'bar') { // do something } else { // do something else } Is that really a confusion? Unlesselse might become a dog though, not sure about that: unless (foo === 'bar') { // do something } unlesselse (foo === 'baz') { // do something } else { // do something else } At that point you'd just want to be using a switch, but that is the same for if's. As I said unless should not really use an else, otherwise you'd be better off just using an if and swapping it around, but having it doesn't hurt. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: email at philsturgeon dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: It looks like this conversation dried up after the rather out-of-context confusion over unless somehow meaning "more". Can we move past that please, as it's a ridiculous non-issue. Previous Comments: [2012-07-30 15:09:00] email at philsturgeon dot co dot uk Rasmus: toby was not suggesting that "uniqid" is the opposite of "iqid", he is saying that you can have "un" at the start of a function or keyword without it automatically flipping the meaning of the next few letters and confusing people - as you suggested in your comment yesterday. In neither situation does "un" switch the meaning of the following letters, so if it is ok for one function/keyword it should be ok for another, right? I don't want to argue, I just want to make sure people are clear. I would hate to see this conversation derailed by confusion or people loudly agreeing. [2012-07-30 15:00:31] ras...@php.net Now you are just being silly. "uniqid" is "unique id" from the latin root "uni" meaning one or singular. Makes perfect sense . It isn't "un" anything. [2012-07-30 13:19:47] mail at tobyinkster dot co dot uk FWIW, while Perl does allow unless (foo) { bar } else { baz } I've never seen it in the wild. I've only ever seen unless used without any trailing else conditions. (And although Perl syntax allows else following unless, it explicitly disallows elsif following unless.) I'd be perfectly happy for PHP to forbid both elseif and else after unless. > It also isn't a very common feature in other languages Latin had "nisi". Modern languages derived from Latin are all the poorer for having lost this concept. > It is an odd word that essentially means not-if even though > it logically should be equivalent to "more" as in the > opposite of "more" would be "less" and sticking "un" in > front of it suddenly completely changes the meaning entirely. By that logic, uniqid() should return the opposite of the iqid() function. [2012-07-29 21:42:28] email at philsturgeon dot co dot uk In regards to double negatives, I agree. If I see a developer do this unless a != 7 then I would block their PR and instantly go and have a talk with them about writing sane code. As for else it really shouldn't be used that much but it should be possible. unless (foo === 'bar') { // do something } else { // do something else } Is that really a confusion? Unlesselse might become a dog though, not sure about that: unless (foo === 'bar') { // do something } unlesselse (foo === 'baz') { // do something } else { // do something else } At that point you'd just want to be using a switch, but that is the same for if's. As I said unless should not really use an else, otherwise you'd be better off just using an if and swapping it around, but having it doesn't hurt. [2012-07-29 21:35:45] kinghfb+php at gmail dot com The structure adds sugar without necessarily breaking anything (with the exception of existing unless() functions, as Rasmus mentioned). I really don't think the double-negatives argument works here, as we're already doing that with 'if', meaning that the readability is quite low in some cases. My only concern is that the structure seems to be more easily convoluted than 'if', potentially leading to nightmarish comprehension tasks. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: email at philsturgeon dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: Rasmus: toby was not suggesting that "uniqid" is the opposite of "iqid", he is saying that you can have "un" at the start of a function or keyword without it automatically flipping the meaning of the next few letters and confusing people - as you suggested in your comment yesterday. In neither situation does "un" switch the meaning of the following letters, so if it is ok for one function/keyword it should be ok for another, right? I don't want to argue, I just want to make sure people are clear. I would hate to see this conversation derailed by confusion or people loudly agreeing. Previous Comments: [2012-07-30 15:00:31] ras...@php.net Now you are just being silly. "uniqid" is "unique id" from the latin root "uni" meaning one or singular. Makes perfect sense . It isn't "un" anything. [2012-07-30 13:19:47] mail at tobyinkster dot co dot uk FWIW, while Perl does allow unless (foo) { bar } else { baz } I've never seen it in the wild. I've only ever seen unless used without any trailing else conditions. (And although Perl syntax allows else following unless, it explicitly disallows elsif following unless.) I'd be perfectly happy for PHP to forbid both elseif and else after unless. > It also isn't a very common feature in other languages Latin had "nisi". Modern languages derived from Latin are all the poorer for having lost this concept. > It is an odd word that essentially means not-if even though > it logically should be equivalent to "more" as in the > opposite of "more" would be "less" and sticking "un" in > front of it suddenly completely changes the meaning entirely. By that logic, uniqid() should return the opposite of the iqid() function. [2012-07-29 21:42:28] email at philsturgeon dot co dot uk In regards to double negatives, I agree. If I see a developer do this unless a != 7 then I would block their PR and instantly go and have a talk with them about writing sane code. As for else it really shouldn't be used that much but it should be possible. unless (foo === 'bar') { // do something } else { // do something else } Is that really a confusion? Unlesselse might become a dog though, not sure about that: unless (foo === 'bar') { // do something } unlesselse (foo === 'baz') { // do something } else { // do something else } At that point you'd just want to be using a switch, but that is the same for if's. As I said unless should not really use an else, otherwise you'd be better off just using an if and swapping it around, but having it doesn't hurt. [2012-07-29 21:35:45] kinghfb+php at gmail dot com The structure adds sugar without necessarily breaking anything (with the exception of existing unless() functions, as Rasmus mentioned). I really don't think the double-negatives argument works here, as we're already doing that with 'if', meaning that the readability is quite low in some cases. My only concern is that the structure seems to be more easily convoluted than 'if', potentially leading to nightmarish comprehension tasks. [2012-07-29 20:36:46] hi at brennannovak dot com I like this idea quite a bit- of course I am a native english speaker as well (American), but considering this is used in Ruby & Python the language barrier is not too great that it hinders use. Additionally there are *many* abbreviations in PHP that consist of multiple "english" words which developers are able to understand such as strcmp() Once I memorize what a group of characters *do* I stop thinking about the words that make up the function. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: email at philsturgeon dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: In regards to double negatives, I agree. If I see a developer do this unless a != 7 then I would block their PR and instantly go and have a talk with them about writing sane code. As for else it really shouldn't be used that much but it should be possible. unless (foo === 'bar') { // do something } else { // do something else } Is that really a confusion? Unlesselse might become a dog though, not sure about that: unless (foo === 'bar') { // do something } unlesselse (foo === 'baz') { // do something } else { // do something else } At that point you'd just want to be using a switch, but that is the same for if's. As I said unless should not really use an else, otherwise you'd be better off just using an if and swapping it around, but having it doesn't hurt. Previous Comments: [2012-07-29 21:35:45] kinghfb+php at gmail dot com The structure adds sugar without necessarily breaking anything (with the exception of existing unless() functions, as Rasmus mentioned). I really don't think the double-negatives argument works here, as we're already doing that with 'if', meaning that the readability is quite low in some cases. My only concern is that the structure seems to be more easily convoluted than 'if', potentially leading to nightmarish comprehension tasks. [2012-07-29 20:36:46] hi at brennannovak dot com I like this idea quite a bit- of course I am a native english speaker as well (American), but considering this is used in Ruby & Python the language barrier is not too great that it hinders use. Additionally there are *many* abbreviations in PHP that consist of multiple "english" words which developers are able to understand such as strcmp() Once I memorize what a group of characters *do* I stop thinking about the words that make up the function. [2012-07-29 20:25:43] email at philsturgeon dot co dot uk Thanks for stopping by Rasmus, that was a really quick follow up. I think you might have pointed out the crux of the confusion: being a native English speaker. To me it makes perfect sense, but I am British. Unless the condition is true, do this. I like the post: https://37signals.com/svn/posts/2699-making-sense-with-rubys- unless A new keyword just to replace "if ( ! (condition))" might seem like a hassle, and the objective of the game is not always to make PHP "nice", but it is readable and logical to many, and is easy to ignore if you don't like it - unless you have function unless(), but the chances are that function is doing something similar anyway. [2012-07-29 20:16:53] ras...@php.net Any new keyword breaks BC to some extent because it will break any code that has an existing unless() function. I agree with others here that unless() can be quite confusing. A negated conditional keyword lends itself to double negatives. It also isn't a very common feature in other languages and definitely not obvious to non-native English speaking people like myself. It is an odd word that essentially means not-if even though it logically should be equivalent to "more" as in the opposite of "more" would be "less" and sticking "un" in front of it suddenly completely changes the meaning entirely. [2012-07-29 20:00:40] email at philsturgeon dot co dot uk I am surprised to see such a lack of interest on this feature request. Ruby and Perl both have "unless", and while that is certainly not a reason on its own, it does show that this is used. There are two people here saying that unless is confusing. How so? If something matches false then do whatever. It has an else too, so if something is true it will be used. The main point here is not to remove a single !, but to make much cleaner syntax. if ( ! (isset($foo) or ($foo !== 'bar')) exit('invalid value'); or unless (isset($foo) and $foo === 'bar') exit('invalid value'); Its a minor difference as I cannot remember a more compelling example, but there have been numerous times I have wished to reverse this and have unless instead of an extremely complex if statement. Unless just makes sense, it's optional, it doesn't break BC, it makes syntax easier to read in
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: kinghfb+php at gmail dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: The structure adds sugar without necessarily breaking anything (with the exception of existing unless() functions, as Rasmus mentioned). I really don't think the double-negatives argument works here, as we're already doing that with 'if', meaning that the readability is quite low in some cases. My only concern is that the structure seems to be more easily convoluted than 'if', potentially leading to nightmarish comprehension tasks. Previous Comments: [2012-07-29 20:36:46] hi at brennannovak dot com I like this idea quite a bit- of course I am a native english speaker as well (American), but considering this is used in Ruby & Python the language barrier is not too great that it hinders use. Additionally there are *many* abbreviations in PHP that consist of multiple "english" words which developers are able to understand such as strcmp() Once I memorize what a group of characters *do* I stop thinking about the words that make up the function. [2012-07-29 20:25:43] email at philsturgeon dot co dot uk Thanks for stopping by Rasmus, that was a really quick follow up. I think you might have pointed out the crux of the confusion: being a native English speaker. To me it makes perfect sense, but I am British. Unless the condition is true, do this. I like the post: https://37signals.com/svn/posts/2699-making-sense-with-rubys- unless A new keyword just to replace "if ( ! (condition))" might seem like a hassle, and the objective of the game is not always to make PHP "nice", but it is readable and logical to many, and is easy to ignore if you don't like it - unless you have function unless(), but the chances are that function is doing something similar anyway. [2012-07-29 20:16:53] ras...@php.net Any new keyword breaks BC to some extent because it will break any code that has an existing unless() function. I agree with others here that unless() can be quite confusing. A negated conditional keyword lends itself to double negatives. It also isn't a very common feature in other languages and definitely not obvious to non-native English speaking people like myself. It is an odd word that essentially means not-if even though it logically should be equivalent to "more" as in the opposite of "more" would be "less" and sticking "un" in front of it suddenly completely changes the meaning entirely. [2012-07-29 20:00:40] email at philsturgeon dot co dot uk I am surprised to see such a lack of interest on this feature request. Ruby and Perl both have "unless", and while that is certainly not a reason on its own, it does show that this is used. There are two people here saying that unless is confusing. How so? If something matches false then do whatever. It has an else too, so if something is true it will be used. The main point here is not to remove a single !, but to make much cleaner syntax. if ( ! (isset($foo) or ($foo !== 'bar')) exit('invalid value'); or unless (isset($foo) and $foo === 'bar') exit('invalid value'); Its a minor difference as I cannot remember a more compelling example, but there have been numerous times I have wished to reverse this and have unless instead of an extremely complex if statement. Unless just makes sense, it's optional, it doesn't break BC, it makes syntax easier to read in some situations and it is easy to document. If I knew enough C I'd send in a patch right now as PHP would be better off for having this. [2011-12-30 13:50:47] joke at nakhon dot net I vote against this request. Both perl and ruby's 'unless' confuse me so much. It can be easy to abuse. I often encounter someone wrote code like this: unless a != 7 b = 3 else b = 6 end The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: hi at brennannovak dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: I like this idea quite a bit- of course I am a native english speaker as well (American), but considering this is used in Ruby & Python the language barrier is not too great that it hinders use. Additionally there are *many* abbreviations in PHP that consist of multiple "english" words which developers are able to understand such as strcmp() Once I memorize what a group of characters *do* I stop thinking about the words that make up the function. Previous Comments: [2012-07-29 20:25:43] email at philsturgeon dot co dot uk Thanks for stopping by Rasmus, that was a really quick follow up. I think you might have pointed out the crux of the confusion: being a native English speaker. To me it makes perfect sense, but I am British. Unless the condition is true, do this. I like the post: https://37signals.com/svn/posts/2699-making-sense-with-rubys- unless A new keyword just to replace "if ( ! (condition))" might seem like a hassle, and the objective of the game is not always to make PHP "nice", but it is readable and logical to many, and is easy to ignore if you don't like it - unless you have function unless(), but the chances are that function is doing something similar anyway. [2012-07-29 20:16:53] ras...@php.net Any new keyword breaks BC to some extent because it will break any code that has an existing unless() function. I agree with others here that unless() can be quite confusing. A negated conditional keyword lends itself to double negatives. It also isn't a very common feature in other languages and definitely not obvious to non-native English speaking people like myself. It is an odd word that essentially means not-if even though it logically should be equivalent to "more" as in the opposite of "more" would be "less" and sticking "un" in front of it suddenly completely changes the meaning entirely. [2012-07-29 20:00:40] email at philsturgeon dot co dot uk I am surprised to see such a lack of interest on this feature request. Ruby and Perl both have "unless", and while that is certainly not a reason on its own, it does show that this is used. There are two people here saying that unless is confusing. How so? If something matches false then do whatever. It has an else too, so if something is true it will be used. The main point here is not to remove a single !, but to make much cleaner syntax. if ( ! (isset($foo) or ($foo !== 'bar')) exit('invalid value'); or unless (isset($foo) and $foo === 'bar') exit('invalid value'); Its a minor difference as I cannot remember a more compelling example, but there have been numerous times I have wished to reverse this and have unless instead of an extremely complex if statement. Unless just makes sense, it's optional, it doesn't break BC, it makes syntax easier to read in some situations and it is easy to document. If I knew enough C I'd send in a patch right now as PHP would be better off for having this. [2011-12-30 13:50:47] joke at nakhon dot net I vote against this request. Both perl and ruby's 'unless' confuse me so much. It can be easy to abuse. I often encounter someone wrote code like this: unless a != 7 b = 3 else b = 6 end [2011-08-04 20:59:24] achaia3 at gmail dot com This would be a convenient feature for sure with no down sides for anybody not wishing to use it. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: email at philsturgeon dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Wont fix Type: Feature/Change Request Package:*General Issues Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: Thanks for stopping by Rasmus, that was a really quick follow up. I think you might have pointed out the crux of the confusion: being a native English speaker. To me it makes perfect sense, but I am British. Unless the condition is true, do this. I like the post: https://37signals.com/svn/posts/2699-making-sense-with-rubys- unless A new keyword just to replace "if ( ! (condition))" might seem like a hassle, and the objective of the game is not always to make PHP "nice", but it is readable and logical to many, and is easy to ignore if you don't like it - unless you have function unless(), but the chances are that function is doing something similar anyway. Previous Comments: [2012-07-29 20:16:53] ras...@php.net Any new keyword breaks BC to some extent because it will break any code that has an existing unless() function. I agree with others here that unless() can be quite confusing. A negated conditional keyword lends itself to double negatives. It also isn't a very common feature in other languages and definitely not obvious to non-native English speaking people like myself. It is an odd word that essentially means not-if even though it logically should be equivalent to "more" as in the opposite of "more" would be "less" and sticking "un" in front of it suddenly completely changes the meaning entirely. [2012-07-29 20:00:40] email at philsturgeon dot co dot uk I am surprised to see such a lack of interest on this feature request. Ruby and Perl both have "unless", and while that is certainly not a reason on its own, it does show that this is used. There are two people here saying that unless is confusing. How so? If something matches false then do whatever. It has an else too, so if something is true it will be used. The main point here is not to remove a single !, but to make much cleaner syntax. if ( ! (isset($foo) or ($foo !== 'bar')) exit('invalid value'); or unless (isset($foo) and $foo === 'bar') exit('invalid value'); Its a minor difference as I cannot remember a more compelling example, but there have been numerous times I have wished to reverse this and have unless instead of an extremely complex if statement. Unless just makes sense, it's optional, it doesn't break BC, it makes syntax easier to read in some situations and it is easy to document. If I knew enough C I'd send in a patch right now as PHP would be better off for having this. [2011-12-30 13:50:47] joke at nakhon dot net I vote against this request. Both perl and ruby's 'unless' confuse me so much. It can be easy to abuse. I often encounter someone wrote code like this: unless a != 7 b = 3 else b = 6 end [2011-08-04 20:59:24] achaia3 at gmail dot com This would be a convenient feature for sure with no down sides for anybody not wishing to use it. [2011-06-05 22:47:45] mattr dot smith at gmail dot com I also request this feature. Ruby has this structure too and really adds to the readability of code. I don't see any argument at against this that is valid other than the fact that PHP programmers don't want to change. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=40296 -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: email at philsturgeon dot co dot uk Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Open Type: Feature/Change Request Package:Feature/Change Request Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: I am surprised to see such a lack of interest on this feature request. Ruby and Perl both have "unless", and while that is certainly not a reason on its own, it does show that this is used. There are two people here saying that unless is confusing. How so? If something matches false then do whatever. It has an else too, so if something is true it will be used. The main point here is not to remove a single !, but to make much cleaner syntax. if ( ! (isset($foo) or ($foo !== 'bar')) exit('invalid value'); or unless (isset($foo) and $foo === 'bar') exit('invalid value'); Its a minor difference as I cannot remember a more compelling example, but there have been numerous times I have wished to reverse this and have unless instead of an extremely complex if statement. Unless just makes sense, it's optional, it doesn't break BC, it makes syntax easier to read in some situations and it is easy to document. If I knew enough C I'd send in a patch right now as PHP would be better off for having this. Previous Comments: [2011-12-30 13:50:47] joke at nakhon dot net I vote against this request. Both perl and ruby's 'unless' confuse me so much. It can be easy to abuse. I often encounter someone wrote code like this: unless a != 7 b = 3 else b = 6 end [2011-08-04 20:59:24] achaia3 at gmail dot com This would be a convenient feature for sure with no down sides for anybody not wishing to use it. [2011-06-05 22:47:45] mattr dot smith at gmail dot com I also request this feature. Ruby has this structure too and really adds to the readability of code. I don't see any argument at against this that is valid other than the fact that PHP programmers don't want to change. [2007-12-31 23:19:51] michael at chunkycow dot com dot au G'day Perl has lots of 'features' in it, although I cannot see how an 'unless' control structure adds to anything but confusion for existing/new developers. [2007-01-31 12:26:42] mail at tobyinkster dot co dot uk Description: It would be nice if PHP had an "unless" control structure so that: unless (...) { ... } would be equivalent to: if (!(...)) { ... } Although the "unless" control structure is actually slightly more verbose (in bytes) than "if", it is arguably a lot more readable in the following examples: unless ($a==0 || $b==0) divide_by($a*$b); versus: if (!($a==0 || $b==0)) divide_by($a*$b); or, equivalently using De Morgan's Law (Google for it): if ($a!=0 && $b!=0) divide_by($a*$b); The "unless" structure uses less punctuation, and more human syntax. I can't imagine how this extra syntax would break any existing scripts. For what it's worth, Perl already has an "unless" control structure. -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: joke at nakhon dot net Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Open Type: Feature/Change Request Package:Feature/Change Request Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: I vote against this request. Both perl and ruby's 'unless' confuse me so much. It can be easy to abuse. I often encounter someone wrote code like this: unless a != 7 b = 3 else b = 6 end Previous Comments: [2011-08-04 20:59:24] achaia3 at gmail dot com This would be a convenient feature for sure with no down sides for anybody not wishing to use it. [2011-06-05 22:47:45] mattr dot smith at gmail dot com I also request this feature. Ruby has this structure too and really adds to the readability of code. I don't see any argument at against this that is valid other than the fact that PHP programmers don't want to change. [2007-12-31 23:19:51] michael at chunkycow dot com dot au G'day Perl has lots of 'features' in it, although I cannot see how an 'unless' control structure adds to anything but confusion for existing/new developers. [2007-01-31 12:26:42] mail at tobyinkster dot co dot uk Description: It would be nice if PHP had an "unless" control structure so that: unless (...) { ... } would be equivalent to: if (!(...)) { ... } Although the "unless" control structure is actually slightly more verbose (in bytes) than "if", it is arguably a lot more readable in the following examples: unless ($a==0 || $b==0) divide_by($a*$b); versus: if (!($a==0 || $b==0)) divide_by($a*$b); or, equivalently using De Morgan's Law (Google for it): if ($a!=0 && $b!=0) divide_by($a*$b); The "unless" structure uses less punctuation, and more human syntax. I can't imagine how this extra syntax would break any existing scripts. For what it's worth, Perl already has an "unless" control structure. -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at https://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: achaia3 at gmail dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Open Type: Feature/Change Request Package:Feature/Change Request Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: This would be a convenient feature for sure with no down sides for anybody not wishing to use it. Previous Comments: [2011-06-05 22:47:45] mattr dot smith at gmail dot com I also request this feature. Ruby has this structure too and really adds to the readability of code. I don't see any argument at against this that is valid other than the fact that PHP programmers don't want to change. [2007-12-31 23:19:51] michael at chunkycow dot com dot au G'day Perl has lots of 'features' in it, although I cannot see how an 'unless' control structure adds to anything but confusion for existing/new developers. [2007-01-31 12:26:42] mail at tobyinkster dot co dot uk Description: It would be nice if PHP had an "unless" control structure so that: unless (...) { ... } would be equivalent to: if (!(...)) { ... } Although the "unless" control structure is actually slightly more verbose (in bytes) than "if", it is arguably a lot more readable in the following examples: unless ($a==0 || $b==0) divide_by($a*$b); versus: if (!($a==0 || $b==0)) divide_by($a*$b); or, equivalently using De Morgan's Law (Google for it): if ($a!=0 && $b!=0) divide_by($a*$b); The "unless" structure uses less punctuation, and more human syntax. I can't imagine how this extra syntax would break any existing scripts. For what it's worth, Perl already has an "unless" control structure. -- Edit this bug report at https://bugs.php.net/bug.php?id=40296&edit=1
Req #40296 [Com]: "unless" control structure
Edit report at http://bugs.php.net/bug.php?id=40296&edit=1 ID: 40296 Comment by: mattr dot smith at gmail dot com Reported by:mail at tobyinkster dot co dot uk Summary:"unless" control structure Status: Open Type: Feature/Change Request Package:Feature/Change Request Operating System: All PHP Version:5.2.0 Block user comment: N Private report: N New Comment: I also request this feature. Ruby has this structure too and really adds to the readability of code. I don't see any argument at against this that is valid other than the fact that PHP programmers don't want to change. Previous Comments: [2007-12-31 23:19:51] michael at chunkycow dot com dot au G'day Perl has lots of 'features' in it, although I cannot see how an 'unless' control structure adds to anything but confusion for existing/new developers. [2007-01-31 12:26:42] mail at tobyinkster dot co dot uk Description: It would be nice if PHP had an "unless" control structure so that: unless (...) { ... } would be equivalent to: if (!(...)) { ... } Although the "unless" control structure is actually slightly more verbose (in bytes) than "if", it is arguably a lot more readable in the following examples: unless ($a==0 || $b==0) divide_by($a*$b); versus: if (!($a==0 || $b==0)) divide_by($a*$b); or, equivalently using De Morgan's Law (Google for it): if ($a!=0 && $b!=0) divide_by($a*$b); The "unless" structure uses less punctuation, and more human syntax. I can't imagine how this extra syntax would break any existing scripts. For what it's worth, Perl already has an "unless" control structure. -- Edit this bug report at http://bugs.php.net/bug.php?id=40296&edit=1