| ▲ | adrian_b 2 hours ago | |
Already in 1963, the language CPL introduced "unless ... do ...", besides the "if ... do ..." inherited from ALGOL 60. Perl has just followed the example of CPL and BCPL, decades later. Using "if" or "unless", whichever is more appropriate, is far more readable than "guard". Moreover, there are many languages where an assignment or an initialization can appear in any place where an expression can appear. Such general rules are always better than special rules like allowing new bindings in a "guard", but not in an "if". Pattern matching does not need any special syntax, it should work in the standard alternative program structure of that programming language, regardless whether it is called "select", "case" or "switch". It always annoys me when the creators of new programming languages demonstrate amateurism, by inventing new worse alternatives than those that existed in various older programming language, already many decades ago. There are plenty of new programming languages that claim to be better than C, which may be true, but they fail to match programming languages much older than C. | ||
| ▲ | klausa 2 hours ago | parent [-] | |
You’ve missed (or ignored) the “compiler enforces leaving the scope” part. | ||