Re: [PHP] Re: Inspiration for a Tombstone.
2008/7/2 Daniel Brown [EMAIL PROTECTED]: Fatal error: Call to undefined function shawn() in /home/shawn/life.php on line 1 I like it. ;-P I think that a 500 internal service error would be more appropriate at that stage... Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Re: [PHP] Re: Inspiration for a Tombstone.
On Mon, Jun 30, 2008 at 1:31 PM, Shawn McKenzie [EMAIL PROTECTED] wrote: Fatal error: Call to undefined function shawn() in /home/shawn/life.php on line 1 I like it. ;-P -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie [EMAIL PROTECTED] wrote: Robert Cummings wrote: I will never do it... it looks ugly, Only if you're not used to it. IMO this is how it should be taught in all the books and guides etc. If that was the case, the other way round would be ugly :) especially when performing multiple if comparisons on the variable. Perhaps, but it's still not as ugly as a hideous error gone undetected which accidentally deletes all your customers' data. ---snip--- I don't know about ugly, but I agree it feels wrong. I feel like I'm using Yoda-speak when reading code like that: If 'yes' is you_can_read_this, 'Stop standing on me' I say. or If 0 is my_pulse then 'dead you are' should say you. :-D --Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote: On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie [EMAIL PROTECTED] wrote: Robert Cummings wrote: I will never do it... it looks ugly, Only if you're not used to it. IMO this is how it should be taught in all the books and guides etc. If that was the case, the other way round would be ugly :) especially when performing multiple if comparisons on the variable. Perhaps, but it's still not as ugly as a hideous error gone undetected which accidentally deletes all your customers' data. ---snip--- I don't know about ugly, but I agree it feels wrong. I feel like I'm using Yoda-speak when reading code like that: If 'yes' is you_can_read_this, 'Stop standing on me' I say. or If 0 is my_pulse then 'dead you are' should say you. *lol* Exactly... just doesn't sit right. It's a good way to make sure you're not screwing up, but testing should take care of that too. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
Robert Cummings wrote: On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote: On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie [EMAIL PROTECTED] wrote: Robert Cummings wrote: I will never do it... it looks ugly, Only if you're not used to it. IMO this is how it should be taught in all the books and guides etc. If that was the case, the other way round would be ugly :) especially when performing multiple if comparisons on the variable. Perhaps, but it's still not as ugly as a hideous error gone undetected which accidentally deletes all your customers' data. ---snip--- I don't know about ugly, but I agree it feels wrong. I feel like I'm using Yoda-speak when reading code like that: If 'yes' is you_can_read_this, 'Stop standing on me' I say. or If 0 is my_pulse then 'dead you are' should say you. *lol* Exactly... just doesn't sit right. It's a good way to make sure you're not screwing up, but testing should take care of that too. Cheers, Rob. But whoever said the flow of the English language was all that efficient? I actually prefer 'Yoda Speak'. Takes less to say more. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
2008/6/28 Jim Lucas [EMAIL PROTECTED]: But whoever said the flow of the English language was all that efficient? I actually prefer 'Yoda Speak'. Takes less to say more. The flow of the English language was all that efficient, who ever said? 'Yoda speak' I actually prefer. Say more, takes less. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Re: [PHP] Re: Inspiration for a Tombstone.
On Sat, 2008-06-28 at 21:19 +0300, Dotan Cohen wrote: 2008/6/28 Jim Lucas [EMAIL PROTECTED]: But whoever said the flow of the English language was all that efficient? I actually prefer 'Yoda Speak'. Takes less to say more. The flow of the English language was all that efficient, who ever said? 'Yoda speak' I actually prefer. Say more, takes less. Don't forget the associated function of understanding... Yoda speak requires more thinking and you still understand less. Yoda speak is merely a veiled attempt to seem wise. Wisdom real requires such tricks not. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
On Sat, Jun 28, 2008 at 1:33 PM, Jim Lucas [EMAIL PROTECTED] wrote: Robert Cummings wrote: On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote: On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie [EMAIL PROTECTED] wrote: Robert Cummings wrote: I will never do it... it looks ugly, Only if you're not used to it. IMO this is how it should be taught in all the books and guides etc. If that was the case, the other way round would be ugly :) especially when performing multiple if comparisons on the variable. Perhaps, but it's still not as ugly as a hideous error gone undetected which accidentally deletes all your customers' data. ---snip--- I don't know about ugly, but I agree it feels wrong. I feel like I'm using Yoda-speak when reading code like that: If 'yes' is you_can_read_this, 'Stop standing on me' I say. or If 0 is my_pulse then 'dead you are' should say you. *lol* Exactly... just doesn't sit right. It's a good way to make sure you're not screwing up, but testing should take care of that too. Cheers, Rob. But whoever said the flow of the English language was all that efficient? I actually prefer 'Yoda Speak'. Takes less to say more. Say anything about efficiency never did I. :-) I was merely commenting on a personal preference based largely on my perspective as a native speaker of (US) English. Now - if I WERE to address efficiency, I don't find Yoda speak to be any more efficient. It's usually the same words just in a different order. What's more that order, while quite natural for some languages, is not natural to me at all. As Bob mentioned, it requires a little extra thought for my brain to push certain phrases onto the mental stack before I can pop them off in an order that makes sense. In programming terms, any code that requires the same amount of statements but requires more cycles to process is not what I would consider more efficient. As far as the programming practice that Colin was advocating, it is not a bad habit. And as far as the computer is concerned, the efficiency is a wash since the number of internal steps probably doesn't change much. However, it doesn't always work. (I know - no one claimed it did.) ?php if ($challenge_password_hash = $stored_password_hash) { echo 'Welcome to the club!'; } else { echo 'Stay out! This club is for members only!'; } ? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
2008/6/28 Andrew Ballard [EMAIL PROTECTED]: Say anything about efficiency never did I. :-) I was merely commenting on a personal preference based largely on my perspective as a native speaker of (US) English. Now - if I WERE to address efficiency, I don't find Yoda speak to be any more efficient. It's usually the same words just in a different order. What's more that order, while quite natural for some languages, is not natural to me at all. As Bob mentioned, it requires a little extra thought for my brain to push certain phrases onto the mental stack before I can pop them off in an order that makes sense. In programming terms, any code that requires the same amount of statements but requires more cycles to process is not what I would consider more efficient. As far as the programming practice that Colin was advocating, it is not a bad habit. And as far as the computer is concerned, the efficiency is a wash since the number of internal steps probably doesn't change much. However, it doesn't always work. (I know - no one claimed it did.) ?php if ($challenge_password_hash = $stored_password_hash) { echo 'Welcome to the club!'; } else { echo 'Stay out! This club is for members only!'; } ? Andrew In these instances you could rely on != behaviour instead of == behaviour, like this: ?php if ($challenge_password_hash != $stored_password_hash) { echo 'Stay out! This club is for members only!'; } else { echo 'Welcome to the club!'; } ? or, better yet: ?php if ($challenge_password_hash != $stored_password_hash) { echo 'Stay out! This club is for members only!'; exit; } echo 'Welcome to the club!'; // Lots of code here that just saved itself another indent in my IDE ? Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Re: [PHP] Re: Inspiration for a Tombstone.
2008/6/27 Colin Guthrie [EMAIL PROTECTED]: As I very humorously hinted at in a earlier mail on this thread, it is a very, very good idea to get into the habit of putting constants *first* in if/while/etc statements. if (Dan S = $user_name) PHP/C/C++ etc. Bombs with a syntax error. That is a great tip, thanks! Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
RE: [PHP] Re: Inspiration for a Tombstone.
[snip] Really? I do it this way: if ($user_name == Dan S) That not only looks right at first glance, but it actually works. :-) [/snip] This works better though; if(Dan S == $user_name) ... if you drop one of the comparison operators in your haste to type then an error gets thrown and you will be able to find it precisely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Inspiration for a Tombstone.
At 8:30 AM -0500 6/27/08, Jay Blanchard wrote: [snip] Really? I do it this way: if ($user_name == Dan S) That not only looks right at first glance, but it actually works. :-) [/snip] This works better though; if(Dan S == $user_name) ... if you drop one of the comparison operators in your haste to type then an error gets thrown and you will be able to find it precisely. Ah yes, and this works even better. if('Dan S' == $user_name) ... also, no need for double quotes And being dyslexic, I knew the 'Dan S' should have come first, but didn't immediately recognize it as I was rushing to point out a double equal-sign boo-boo made by Col. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Inspiration for a Tombstone.
[snip] And being dyslexic, I knew the 'Dan S' should have come first, but didn't immediately recognize it as I was rushing to point out a double equal-sign boo-boo made by Col. [/snip] Had Col used the method we're speaking of here the error would have been thrown and he would have found the culprit post haste. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Inspiration for a Tombstone.
On Fri, Jun 27, 2008 at 6:01 AM, Colin Guthrie [EMAIL PROTECTED] wrote: As I very humorously hinted at in a earlier mail on this thread, it is a very, very good idea to get into the habit of putting constants *first* in if/while/etc statements. if (Dan S = $user_name) PHP/C/C++ etc. Bombs with a syntax error. if ($user_name = Dan S) Works silently and looks right at first glance. I forced myself to write things that way round a good number of years ago and it has served me well and caught a few potential mishaps. You raise a very good and valid point, Col. I format my code that way with C/C++, BASH, even Tcl/Tk (yeah, I said it), but for some reason I never remember to do it in PHP. I think it's time to start forcing myself to develop that habit. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Inspiration for a Tombstone.
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2008 8:50 AM To: tedd; php-general@lists.php.net Subject: RE: [PHP] Re: Inspiration for a Tombstone. [snip] And being dyslexic, I knew the 'Dan S' should have come first, but didn't immediately recognize it as I was rushing to point out a double equal-sign boo-boo made by Col. [/snip] Had Col used the method we're speaking of here the error would have been thrown and he would have found the culprit post haste. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think you guys are missing something: he wrote it with single equals signs on purpose. He was demonstrating how the one with the constant to the right of the assignment operator is a valid statement... and that putting the constant first will aid you in finding such mistakes. if(constant = $variable){} // bombs, and lets you know right away you missed an = if($variable = constant){} // assigns rather than compares, but nonetheless is valid code To quote Colin: As I very humorously hinted at in a earlier mail on this thread, it is a very, very good idea to get into the habit of putting constants *first* in if/while/etc statements. So, I'm sure he is well familiar with this method we're speaking of. :) Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Inspiration for a Tombstone.
At 9:52 AM -0500 6/27/08, Boyd, Todd M. wrote: I think you guys are missing something: he wrote it with single equals signs on purpose. He was demonstrating how the one with the constant to the right of the assignment operator is a valid statement... and that putting the constant first will aid you in finding such mistakes. No question -- I missed the intent. But in my defense, a single equal sign in an if statement stands out like a red flag to me and thus I really don't need help finding it. When my code craters, it's usually for things other than that. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Inspiration for a Tombstone.
On Fri, 2008-06-27 at 09:52 -0500, Boyd, Todd M. wrote: -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2008 8:50 AM To: tedd; php-general@lists.php.net Subject: RE: [PHP] Re: Inspiration for a Tombstone. [snip] And being dyslexic, I knew the 'Dan S' should have come first, but didn't immediately recognize it as I was rushing to point out a double equal-sign boo-boo made by Col. [/snip] Had Col used the method we're speaking of here the error would have been thrown and he would have found the culprit post haste. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think you guys are missing something: he wrote it with single equals signs on purpose. He was demonstrating how the one with the constant to the right of the assignment operator is a valid statement... and that putting the constant first will aid you in finding such mistakes. if(constant = $variable){} // bombs, and lets you know right away you missed an = if($variable = constant){} // assigns rather than compares, but nonetheless is valid code To quote Colin: As I very humorously hinted at in a earlier mail on this thread, it is a very, very good idea to get into the habit of putting constants *first* in if/while/etc statements. So, I'm sure he is well familiar with this method we're speaking of. :) I will never do it... it looks ugly, especially when performing multiple if comparisons on the variable. Additionally, using a little red to highlight the assignment operator but not the comparison operator works just as well. Make machines work for you, not the other way around. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php