Skip to content

Instantly share code, notes, and snippets.

@matey-jack
Last active January 25, 2019 21:14
Show Gist options
  • Save matey-jack/931329df76ec948b32bc78e2693fbcaf to your computer and use it in GitHub Desktop.
Save matey-jack/931329df76ec948b32bc78e2693fbcaf to your computer and use it in GitHub Desktop.
different languages – different results

Giving a different result on the exact same program is pretty confusing and the exact opposite of what Dart-lang stands for until now, namely simplicity and consistency.

If Dart-lang were ever to introduce optional semicolons then the only way out of not disagreeing with any of the above languages is to not allow the above expression to compile in the first place.

Looks like the current proposal for no-semicolons-Dart actually goes the Kotlin way: https://github.com/dart-lang/language/blob/terminating-tokens/working/terminating-tokens/feature-specification.md

Without knowing stuff myself, but from what I gather from the proposal:

  • Most languages other than JS have semicolon-rules more like Kotlin.
  • Most languages also have non-lexical semicolon-rules, meaning that context matters, which is sad, but still simple enough. (Exception is Go, where statement-termination is determined by the lexer already, based only on the token that's before a newline.)
// Javascript
function test() {
return 1 + 1
+ 2
+ 3
}
console.log('Hello, world! ' + test());
// Kotlin
fun test(): kotlin.Int {
return 1 + 1
+ 2
+ 3
}
fun main(args: Array<String>) {
println("Hello, world! ${test()}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment