A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-January/001900.html below:

[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 guido@CNRI.Reston.VA.US
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/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4