On 2006-11-09, Bjoern Schliessmann
<[EMAIL PROTECTED]> 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to