<div dir="ltr">On 19 April 2014 06:54, Andrew Barnert <a href="http://abarnert-at-yahoo.com" target="_blank">abarnert-at-yahoo.com</a> |<a href="http://python-ideas-at-python.org" target="_blank">python-ideas-at-python.org</a>| <span dir="ltr"><<a href="mailto:3en9kh2cbt@sneakemail..com" target="_blank">3en9kh2cbt@sneakemail.com</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div> switch mystring case "spam":</div><div> process(thingy)</div><div><br></div>
<div>That is not even remotely interpretable as an English sentence. That's not a problem for C, but it is for Python.</div></blockquote><br><div>I'll think about a possible solution.<br><br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
I don't see how skipping over any elcase but falling through to the next case is in any way simpler than C.</blockquote><div><div dir="ltr"><div class="gmail_extra"><div><div><div>Well, because it's coherent with <span style="font-family:courier new,monospace">if-elif</span>. See my last example in my first message.</div>
</div></div></div></div></div></div></blockquote>No
it isn't. An elif clause is embedded in an if statement; there is no if
clause you can embed on an if statement, just an entirely new and
unrelated if statement. <br></blockquote><br></div><div>I can assert,
without fear of contradictions, that my proposed syntax is the closest
to the if-elif syntax of all the switch statement proposed until now in
the age of Python.<br>
</div><div><br><br><br></div><div>About off-topic arguments:<br></div><br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"> bash does not have either ";;&" or ";&"<br>
</blockquote><div> </div><div><a href="http://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html" target="_blank">http://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html</a> <br>
</div>
<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Who asked you about list comprehensions or lambdas? What do you think
they have to do with anything?<br>[...]<br>I have no idea why you think recursive functions are relevant to anything being discussed here.<br>[...]your
proposal was to treat tuples specially and match all other
iterables as single values, which means that a generator expression
would be matched as a single value, meaning it would only match itself.
And again, I don't understand what the relevance is supposed to be.
</blockquote><div><br></div><div>I premise that pattern recognition is outside the scope of my switch proposal. Anyway:<br></div><div><ol><li>About
list comprehensions and lambdas, you talked about assignment
statements, and AFAIK the only pattern matching things that are somewhat
related to assignment statement are the possibility to filter a list
comprehension and the use of lambdas. If you mean something different
you should be more explicit, instead of saying "what? where? why?"<br></li><li>About recursive function, I wronged. Sorry but it was late.</li><li>About
generators, you can create a generator, convert it to an iterable and
unpack it in a case_expr. I could also extend the current syntax and
support a "generator unpacking". This way you'll have a limited
alternative to pattern matching in some cases in a switch statement
without the need to create a static iterable.</li></ol></div></div>