GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing mail.python.org — [Python-Dev] Adding C ternary select (a?b:c) to Python? [Python-Dev] Adding C ternary select (a?b:c) to Python?Guido van Rossum [email protected]Mon, 31 Jan 2000 09:36:52 -0500
> I find Ping's proposed syntax intriguing. Personally, I've always been > partial to the > > x = if a then b else c > > syntax, even though I don't think I've ever used a language that > includes it. (Oh wait, the toy ALGOL-knockoff that we used in Intro to > Compilers had it, so I *have* written a parser and simplistic code > generator for a language that includes it. Perhaps that's why I like > it...) Yes, this was in original Algol 60 and, by magic of a completely different kind, again in Algol 68 (which was a completely different language, and the Mount Everest of languages). > But either of these -- ie. elevate "then" to keywordhood, with or > without "if", and no colons to be seen -- smell like they would play > havoc with Python's grammar. And they turn a statement keyword "if" > into an expression keyword. Not being at all familiar with Python's > parser, I should just shut up now, but it feels tricky. The solution can be the same as what Algol used: 'if' outside parentheses is a statement, and inside parentheses is an expression. It's a bit of a grammar rearrangement, but totally unambiguous. However, the added keyword means it won't be in 1.6. The lively discussion means that Eric's patch will have a hard time getting in too... --Guido van Rossum (home page: http://www.python.org/~guido/)
|
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |