For review: PEP 308 - If-then-else expression

Andrew Koenig ark at research.att.com
Sat Feb 8 09:33:30 EST 2003


Erik> Andrew Koenig wrote:

>> Exactly the same argument applies to lambda expressions and list
>> comprehensions.

Erik> And practically every language feature that's been added since
Erik> the earliest version.  Most languages can be boiled down to a
Erik> tiny subset of their basic control structures that are exactly
Erik> as expressive (in the Turing-complete sort of meaning) as the
Erik> original, but that hardly means that the extra syntaxes (such as
Erik> the for control structure in Python; you can write than in terms
Erik> of a while) are mere syntactical sugar.

Indeed.  Some languages (ML and Scheme come to mind) define a core
set of features and then define the rest of the language in terms of
the core.  For example, if I remember right, in ML the definition of

        if <expr> then <expr1> else <expr2>

is

        case <expr> in true => <expr1> | <false> => <expr2>

In other words, in ML, an if-expression is just an abbreviation for
a particular kind of case-expression, and so on.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list