Skip to content

Miscellaneous syntax improvements

jckarter edited this page Nov 19, 2010 · 6 revisions

Random ideas for syntax improvements:

  • Make the final ";" in an statement list optional, similar to the optional final "," in an expression list:
    • { foo() }
    • { foo(); bar() }
  • Make { } indicate a nullary statement lambda, implying the () =>:
    • each(bar, { bas() });
    • This would cause an ambiguity in the parsing of if statements and expressions:
      • if (x) { y() } else { z() }
      • However, since an if expression returning lambdas is currently not valid (the two lambdas are of different incompatible types) the ambiguity could always be resolved in favor of the statement form
  • Make the parens around if, while, for and switch optional:
    • if x { y() } else { z() }
    • for x in y { z() }
    • while x { y() }
    • switch x { case y: z() }
    • Looks a bit awkward in the single-statement case, especially with infix expressions:
      • if x y();
      • while x y += z;

Clone this wiki locally