wrote in message news:eb28362c-4f8f-45df-bbf0-582e8ad2b8af@Spark...

Hi everybody!

Has this idea been discussed before?

I find myself writing switch statements in PHP quite rarely. This has a few reasons:

1. It doesn’t have a "strict_types” version
2. It is quite verbose (lots of breaks)
3. It is a statement rather than an expression

Often, if / elseif statements turn out to be shorter, safer and easier to read than the switch statement.
What I’d really love is something like a match expression:


If there are circumstances where a series of if / elseif statements turn out to be shorter, safer and easier to read than a switch statement, then the intelligent thing to do would be to use if / elseif statements instead of trying to make the switch statement more complicated. If your problem with the switch statement is that you sometimes forget to insert a break statement then that is your fault. Try to use the language features as they were intended to be used and not how you would personally like to use them. Millions of other programmers have no problem with the switch statement, and they would not be pleased to have it changed just to deal with your perceived problem with it.

--
Tony Marston


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to