PEP-308 a "simplicity-first" alternative
Bengt Richter
bokr at oz.net
Wed Feb 12 16:02:22 EST 2003
On Tue, 11 Feb 2003 22:19:16 -0500, "Tim Peters" <tim_one at email.msn.com> wrote:
>[Tim, on Holger's minimal-impact "x and y else z"]
>> Redefining truth used to be easier <wink>: I mentioned it to Guido late
>> afternoon, and his reaction was that it must have been cooked up by
>> someone who spent too much time in this thread.
>
>[holger krekel]
>> Indeed. Does this reaction indicate anything in particular?
>
>That he doesn't like it, of course, and that it requires thinking too much
>about it before you can feel comfortable with it. Thought experiment:
>suppose you were designing a new language. Would you consider adopting
>Python's "x and y else z" notation for the new language's conditionals? If
>not, then maybe it's a case of settling for too little.
Does your channeling reveal any taste for chainable forms that could be the basis
for switch-like or cond(a la lisp)-like effects?
It seems like we have parallel efforts going trying to achieve
1. functionality: simple ternary or generalizable short-circuiting
guarded expr chains (ie., an expression version of if/elif/else etc)
2. newbie-friendly menmonics
3. minimalist-friendly syntax
If it's simple ternary, are we just trying to find a spelling of C's ternary that looks ok?
If the ternary is a special case of something more general, should we
a) forget the general for the moment, but try not to select a ternary that paints it out
b) adopt generalizability as a goal
c) decide that it is not a goal, and concentrate on a minimal ternary
>
>> Maybe he could help us by outruling some possibilities so we don't spend
>> another 1000 hours (combined) discussing mute issues. We played around
>> to quite some exhaustion already <wink>. From his original PEP I e.g
>> read that he is not ready to introduce a new keyword for a "minor
>> feature".
>> That's still the case i guess.
>
>It's my part-time job to channel Guido, because he's always overloaded. For
>some reason it doesn't count that I am too <wink>. It occurred to me today
>that the patch Guido wrote two years ago ("if c then a else b"), and the
>suggestion he started with in the PEP last week ("a if c else b"), and the
>newer suggestion he's shown some liking for ("if c: a else: b") have one
>thing in common: they all contain the word "if". As a Professional
>Channeler, my bet is that any spelling that *doesn't* contain "if" is going
>to get rejected in the end for being too obscure. OTOH, "if" says "if" as
>plainly as anything can say "if".
>
>Remember that Guido doesn't want this enough to accept much ugliness in
>order to get it. Indeed, he'd be happy to leave the language alone here.
>
>
Whoops, I think I had another idea:
The old short circuiting "c and x or y" could also work if we had a notation
that said "treat this as true without changing its value even though it might be false".
E.g., suppose {x} meant treat x as true in the context of a logical expression. Then,
c and {x} or y
or maybe for style's sake
c and {x} or {y}
would do it. There's no confusion with a dict literal, since there's no bare
':' inside. (I.e., {x[1:2]} would be ok and the expression
c and {x[1:2]} or 'x'
could have the value [] e.g. if x==[0]
Since this is my idea, of course I like it best ;-)
Regards,
Bengt Richter
More information about the Python-list
mailing list