wrote in message news:7cd2884a-6606-4c3f-8f95-776fd277878b@Spark...
Hi Tony
… you sometimes forget to insert a break statement then that is your
fault.
Any bug in your source code is ultimately your fault. But as mentioned
before human error is inevitable. You can make it easier for your users to
make less mistakes though. Other languages (e.g. Rust or Swift) have
implicit breaks in their switch statements. This has been done for a
reason, I wouldn’t call this a non-issue.
The problem with implicit breaks is that it makes it impossible to group
several conditions with a single break. My previous language use implicit
breaks, and this problem really annoyed me. With PHP I have more control,
and the fact that I have to insert explicit breaks I do not see as an
inconvenience.
Millions of other programmers have no problem with the switch statement
It’s all they know. They don’t complain about null pointers even though it’s
inventor calls it his billion-dollar mistake. The customer rarely knows
what he truly needs.
They know what they want to achieve, and they have to know which language
features are available to help them meet their objectives. The fact that
some language features have turned out to be a big mistake is purely the
fault of the people who introduced those features. Some programmers complain
about some languages features even though they are useful features which
work as advertised as are not deemed to be a mistake - take yourself for
example who is now complaining about issues with the switch statement.
If what you want to achieve can be done better with a series of if/elseif
statements than the switch statement, then why can't you use if/elseif
instead of making the language more complicated?
--
Tony Marston
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php