- From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
- Date: Fri, 08 May 2020 22:52:42 +0000
- To: public-css-archive@w3.org
> Could you point to an example of a widely-used "switch" that has multiple conditionals? Well one could argue that the conditions are implicitly defined to be equality checks between a fixed value specified at the top and another value for each case. So maybe you don't specify the full conditions explicitly, but at least they are there in the idea. Picking the nth value in a list can be converted into a switch form but it seems a different idea to me. https://en.wikipedia.org/wiki/Switch_statement#History says that the origin of the switch is the "definition by cases": > "#F. The function `φ` defined thus > ``` > φ(x1 , ... , xn ) = > φ1(x1 , ... , xn ) if Q1(x1 , ... , xn ), > . . . . . . . . . . . . > φm(x1 , ... , xn ) if Qm(x1 , ... , xn ), > φm+1(x1 , ... , xn ) otherwise, > ``` > where `Q1 , ... , Qm` are mutually exclusive predicates (or `φ(x1 , ... , xn)` shall have the value given by the first clause which applies) is primitive recursive in `φ1, ..., φm+1, Q1, ..., Qm+1`. So there you are, `Q1 , ... , Qm` are the conditions. For a specific programming language example, the following is a common pattern in JS: ```js switch (true) { case cond1(): /* ... */ break; case cond2(): /* ... */ break; case cond3(): /* ... */ break; } ``` -- GitHub Notification of comment by Loirooriol Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5009#issuecomment-626053298 using your GitHub account
Received on Friday, 8 May 2020 22:52:45 UTC