Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Frank M. Kromann
Thanks Andi, It works for me. - Frank > Fixed. > > > At 12:00 PM 10/8/2004 -0400, Jason Garber wrote: > >Hello, > > > > Ergh. I also hope that it can easily be restored to work the way > > it did, even if that was undocumented. The thought of looking > > through ~ 5,000 php scripts bef

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Hartmut Holzgraefe
Wez Furlong wrote: What, if anything, should we do about this? two letters: 'BC' :( -- Hartmut Holzgraefe <[EMAIL PROTECTED]> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Andi Gutmans
Fixed. At 12:00 PM 10/8/2004 -0400, Jason Garber wrote: Hello, Ergh. I also hope that it can easily be restored to work the way it did, even if that was undocumented. The thought of looking through ~ 5,000 php scripts before our upgrade is a bit overwhelming :) -- Best regards, Jason

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Andi Gutmans
I don't think we should do anything about it. From day 1 we treated switch() like a loop as far as break/continue is concerned, mainly because we wanted break/continue to be consistent. You might find this odd but you actually have more power in PHP than in C as you can break out or continue fr

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Wez Furlong
Slightly OT, but while we are on the subject of switch not being C-ish, how about making it so that continue inside a switch block behaves the way it does in C? This C code snippet: while (1) { printf("top\n"); switch (1) { case 1: continue; } printf("

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Christian Schneider
Andi Gutmans wrote: However, I can assure you that from day 1 this was not supposed to work and was documented as such for years already (since the days of PHP 3). If it worked at some point then it was by chance! This would be a good time to accept the defacto standard, redefine switch() in th

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Jason Garber
Hello, Ergh. I also hope that it can easily be restored to work the way it did, even if that was undocumented. The thought of looking through ~ 5,000 php scripts before our upgrade is a bit overwhelming :) -- Best regards, Jasonmailto:[EMAIL PROTECTED] Fri

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Andi Gutmans
I will look into the reason this seems to have changed. However, I can assure you that from day 1 this was not supposed to work and was documented as such for years already (since the days of PHP 3). If it worked at some point then it was by chance! Andi At 05:31 PM 10/8/2004 +0200, Sascha Schu

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Sascha Schumann
Andi, from the feedback it is obvious that the engine supported defaults at places other than the bottom. In all switch-supporting languages I know, it is possible to do this: switch ($expr) { default: /* handle everything EXCEPT "foo" and "bar" */ /* fal

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Derrell . Lipman
"Frank M. Kromann" <[EMAIL PROTECTED]> writes: > It might be documented but it has not always been working like this. I > have some code that I have not touched for over 2 years, and It has workd > with both PHP4 and PHP5 versions (even PHP5-1-0-dev from Aug 19 2004 > 17:03:39 ). After upgrading t

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Frank M. Kromann
Hi Andi, It might be documented but it has not always been working like this. I have some code that I have not touched for over 2 years, and It has workd with both PHP4 and PHP5 versions (even PHP5-1-0-dev from Aug 19 2004 17:03:39 ). After upgrading to PHP5 CVS-HEAD it stopped working. I have no

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Ron Korving
Well, you convinced me (no need to get all physical with me tho ;)). If this is how C acts (which I did not know), then I prefer it to work like this too. I always assumed (which is bad, I know) the default case worked like a "catch all", which catches anything that crosses its path, and therefor n

Re: [PHP-DEV] switch() and default:

2004-10-08 Thread Christian Schneider
Benj Carson wrote: Coming from C (or Java), I find the new behaviour a little strange. If you I fully agree. Although I wouldn't have used the word 'little' here :-) use default to match invalid conditions, putting it at the beginning of a switch doesn't seem to be poor practice to me (putting i

Re: [PHP-DEV] switch() and default:

2004-10-07 Thread Benj Carson
Coming from C (or Java), I find the new behaviour a little strange. If you use default to match invalid conditions, putting it at the beginning of a switch doesn't seem to be poor practice to me (putting it in the middle would be pretty ugly though). IMO, stating what happens to bogus values a

Re: [PHP-DEV] switch() and default:

2004-10-07 Thread Ron Korving
No matter what behaviour PHP shows, I would find it bad coding if you place default anywhere but at the bottom, simply because you might run into unexpected behaviour in other versions of the PHP engine, which I assume you're experiencing now. You could've seen this coming. When you write a switch,

Re: [PHP-DEV] switch() and default:

2004-10-07 Thread David Vance
prints "a" on 4.2.3 Novell, 4.3.3 Linux, 5.0.0 Windows. On Fri, October 8, 2004 12:21 am, Benj Carson said: > Hi, > > Sorry, I forgot to CC my last reply to the list. I noticed similar > behaviour and filed a bug report: 30285. The case described in the bug > report is as follows: > > $x = "a";

Re: [PHP-DEV] switch() and default:

2004-10-07 Thread Benj Carson
Hi, Sorry, I forgot to CC my last reply to the list. I noticed similar behaviour and filed a bug report: 30285. The case described in the bug report is as follows: $x = "a"; switch ($x) { default: echo "default"; break; case "a": echo "a"; break; } // Prints "a" Even though the do

Re: [PHP-DEV] switch() and default:

2004-10-07 Thread Andi Gutmans
It's always been like that and has been documented for ages in the manual. Andi At 08:24 PM 10/7/2004 -0700, Frank M. Kromann wrote: Hello Everyone, I just discovered a small thing in the switch() statement. The position of the default: clause has to be at the end of the code: $a = 1; switch ($a) {

[PHP-DEV] switch() and default:

2004-10-07 Thread Frank M. Kromann
Hello Everyone, I just discovered a small thing in the switch() statement. The position of the default: clause has to be at the end of the code: $a = 1; switch ($a) { default : case 0 : $b = 1; break; case 1 : $b = 2; break; } echo $b; // should print 2 but it pri