What is the result of executing the following code?
+
+$ cat commentary.scala
+object Commentary extends App
+/* This is a long
+ * commentary.
+
+ */
+{
+ println("""This is a long
+commentary.
+
+""")
+}
+$ scalac commentary.scala
+$ scala commentary.scala
+$ cat commentary2.scala
+object Commentary extends App
+/* This is a long \u000acommentary.\u000a\u000a */
+{
+ println("This is a long \u000acommentary.\u000a\u000a")
+}
+$ scalac commentary2.scala
+$ scala commentary2.scala
+
+
+
Both compile and run, printing "This is a long commentary." with extra blank lines.
+
Both compile and run, but the second prints "This is a long acommentary."
+
The second compiles and runs, but the first does not compile.
+
The first compiles and runs, but the second does not compile.
+
+
+
+
+
Explanation
+
+ The first attempt does not compile because the comment introduces a blank line between
+ the beginning of the definition and the left brace on a subsequent line.
+ This is due to how "nl" tokens are inferred. Normally, one "nl" is inserted between
+ tokens on different lines. But if the tokens are separated by a blank line,
+ then two "nl" tokens are inserted, even if the blank line is embedded in a comment.
+ See the Scala specification.
+
+
+ The compiler emits a different error message than the scala runner in this case.
+ The compiler error is: "expected class or object definition" at the left brace.
+ The scala runner compiles its source text for scripting but emits a warning:
+ "Script has a main object but statement is disallowed", and executes the "standalone"
+ statement instead of the App object.
+