On Fri, 2008-09-12 at 11:47 -0400, Eric Gorr wrote: > On Sep 12, 2008, at 11:39 AM, Andrew Ballard wrote: > > > On Fri, Sep 12, 2008 at 9:52 AM, Jochem Maas <[EMAIL PROTECTED]> > > wrote: > >> Luke schreef: > >>> > >>> I wonder if this is a shared trait between C and PHP (since I > >>> understand > >>> PHP > >>> is written in C) that the break; and the default: are placed for > >>> good > >>> practice in all switch statements since they prevent memory leaks? > >> > >> default is not required, never heard it was good practice to always > >> put it > >> in. > > > > I can't say I've ever heard it recommended as good practice from the > > standpoint of performance in any specific language I've ever worked > > with, but I have heard people suggest that you always include an > > explicit default case in any kind of branching logic. It does seem > > useless to say > > > > default: // do nothing > > break; > > > > in a switch block, but I imagine the reasoning behind it is so that > > anyone who reads your code can see that you actually thought about > > what should/would happen if none of the other conditions were true > > rather than ignoring those conditions. > > It is always useful for a 'default:' case, which would normally do > nothing, to include some debug-only code so you can be notified if the > default case is ever hit. Whenever I see an empty or just missing > 'default:' case, I always cringe.
Whenever I see pointless debug fluff just for the sake of not having an empty or omitted default statement I cry. *begins weeping* 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