PEP 308: Pep Update

Robin Becker robin at jessikat.fsnet.co.uk
Thu Feb 27 04:23:09 EST 2003


In article <pan.2003.02.27.06.06.21.230621 at canada.com>, Norman Petry
<npetry1 at canada.com> writes
>On Thu, 27 Feb 2003 14:51:03 +1300, Greg Ewing (using news.cis.dfn.de)
>wrote:
>
.......
>Probably the latter.
>
>I think that the C syntax for the ternary is very poor, mostly because
>there is nothing intuitively obvious about it.
>
>C? trueValue : falseValue
>
>is a bad syntax in general, but _particularly_ for Python because (imho):
>
>1) it uses symbols, rather than keywords, which are meaningless unless the
>reader is already familiar with the construct from another programming
>language (since they have no obvious analogue in mathematics or some
>natural language).  This makes it an especially poor choice for Python,
>which has important applications as a teaching (i.e. first) language.
>

I think you are wrong on this: mathematics, logical calculus,
engineering et al. all use abstract symbolism. It improves communication
amongst those in the field. people seem to have little difficulty in
picking up such syntax.

If we rigorously adopted your approach then 'a+y' would have to be
replaced by 'a add y' or similar. It may be that poor 'dumb' programmers
can't hack symbols if so we're in real trouble.

As to your point about experience I would argue that non english
speakers are in much the same position wrt 'if', 'then' etc as you claim
most are wrt new symbology.

>2) it is arbitrary, in that nothing about the syntax would suggest that
>the trueValue should precede the colon (i.e. C? falseValue : trueValue is
>equally logical, since a more natural order might be False(0) : True(1)).
>The problem is that the symbols used to form the ternary are not
>suggestive enough to convey a clear meaning (admittedly the question mark
>is barely OK). Arbitrary language features are harder to remember, and
>make the language more difficult to use casually.
>

again I think there is a logic especially for left to right, top down
readers. My logic says read left to right seems to imply evaluate left
to right. The decision has to be made before evaluating the alternatives
(modern speculative compilers notwithstanding).

>3) 

I think your point about the ':' being confusing is possibly correct.

+1000 C ? x : y
-1000 further discussion :)
-- 
Robin Becker




More information about the Python-list mailing list