Py3K idea: why not drop the colon?

Neil Cerutti horpner at yahoo.com
Fri Nov 10 15:23:43 CET 2006


On 2006-11-09, Bjoern Schliessmann
<usenet-mail-0306.20.chr0n0ss at spamgourmet.com> wrote:
> What about
>
> if color == red or blue or green:
>     return 'primary'
>
>:)

The Inform 6* programming language supports the serial 'or' (and
'and') and looks just like that. The disadvantage is that the
usual binary logical operators must exist and are spelled
differently. (It uses C's '||' and '&&'.)

  if (color == red or blue or green && color.type == additive) {
      return 'primary';
  }

It also supports a switch statement syntax and semantics that
would fit nicely with Python.

  switch (action) {
    Eat:
      print "Gulp! Delicious, but poisonous.";
      deadflag = 1;
    Taste:
      print "You nibble at one of the corners. Yum!";
    Attack:
      print "What did that mushroom ever to to you?";
    default: 
      print "You can't do that to a mushroom.";
  }

There's no fall-through, and there's no syntax to enable it,
either.

In Python it would hypothetically be:

  switch action:
    Eat:
      print "Gulp! Delicious, but poisonous."
      deadflag = True
    Taste:
      print "You nibble at one of the corners. Yum!"
    Attack:
      print "What did the mushroom ever to to you?"
    default: 
      print "You can't do that to a mushroom."

I've often wanted a "Pythonic" Inform to Inform translator, so I
can leave out all the unecessary (), {} and ;.

 * Inform 6 is a language for implementing text adventures, not
   to be confused with the unrelated language Inform 7.

-- 
Neil Cerutti



More information about the Python-list mailing list