1. 6

  2. 1

    I was thinking of why we needed colons. If we did not use colons then we would have to force people to always use the line continuation (\) operator for multiline breakups of single statements. So on average the colon saves us typing.

    1. 1

      Can you give a concrete example of where that actually happens? This generally shows up in situations where there already can be/must be an open parenthetical going on anyway, which means the colon is strictly redundant in any meaningful sense, but it’s entirely possible I’m genuinely just not thinking of something.


      For example,

      def __init__(foo, bar, baz, quux,
              frob, a, b, c, d):
          self.whatever = thing

      already doesn’t need a continuation marker, and is logically concluded at the ), so the situation is unchanged if we eliminate : from the grammar. Or conversely,

      if a == b and c == d and \
              e == f and g == h:
          return ('jet fuel can weaken steel beams '
              'to the point of structural failure')

      already requires a continuation marker in the conditional, and not in the string continuation.

      (It’s worth noting, by the way, that Pony, which has a very Python-esque grammar, does not need colons.)

      So I’m looking for examples that thread the needle: they do not require a continuation marker, but only if : is required.

      1. 1

        You are correct, sir

        Why are colons required for the if/while/def/class statements?

        The colon is required primarily to enhance readability (one of the results of the experimental ABC language). Consider this:

        if a == b 
            print a


        if a == b: 
            print a

        Notice how the second one is slightly easier to read. Notice further how a colon sets off the example in this FAQ answer; it’s a standard usage in English.

        Another minor reason is that the colon makes it easier for editors with syntax highlighting; they can look for colons to decide when indentation needs to be increased instead of having to do a more elaborate parsing of the program text.

    2. 1

      It reminds me of dogs without fur. You expect it to be there, but it just isn’t and absence of it makes it look sick.

      1. 0

        I notice the README says “an utf-8”. How does the author pronounce utf-8? “oo-tiff-ate”?

        1. 1

          Since the rule is almost entirely phonetic, this is actually quite common among people who have mostly read and written English and not spoken it much or at all.