Re: switch case - to require the break statements seems strange to me

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:58 AM +0100 9/12/08, Luke wrote:
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?

First, the evolution of computer languages from rocks to what we have now has produced numerous logic constructs. Those that are successful, remain and appear again and again in subsequent languages. Those that are not successful fade way. As a result, all languages are converging on a successful set logic constructs.

The CASE statement has been one of those concepts that has been successful and I expect it to remain -- whereas, others like DO/WHILE may fade away -- I never found reason to use it.

I may be wrong, I seem to remember that the CASE statement preceded the ELSE IF statement -- and is one of the reasons why I never use it (being dyslexic is another). If I was THE PHP czar, I would drop-kick ELSE IF -- for me it's perfectly useless and confusing. YMMV.

Second, as for memory leaks??? The CASE statement, nor any other logic configuration, has anything to do with memory leaks -- that's different.

I am sure there are people who will disagree, but a memory leak is a condition that comes about from declaring a memory allocation (a specific size) for a variable and then later upon discarding that variable and releasing its memory back into the free memory an error is made in its size.

In other words, memory leaks are accounting errors in memory allocations that reduces the amount of available free memory OR worse yet, mistakenly assigns memory to new variables that is still in use and has not been released -- all of which can crash a program.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux