It is now possible in Dart to initialize top-level (i.e. static) variables using any expression. The expression gets evaluated lazily. When I first heard about this, my instant reaction was fear because laziness and imperative programming don't really get along. At the time, I hadn't seen the blog post where Gilad admitted that plainly. Hence, I spent a couple hours that night trying to come up with ways this could lead to wackiness. I asked Gilad about it, and he said, "Laziness and statefulness can cause scary problems, I know. You can get into these Hesienbugs, where things only show up when you look, so as you debug the problem disappears." Just to prove the point, I came up with the following Dart program: import "dart:io"; import "dart:math"; var varA = changeVarB(); var varB = 1; int changeVarB() { varB += 1; return 0; } main() { print("$varB"); var seed = new Date.now().millisecondsSinceEpoch; var nextBool = n
This is a purely technical blog concerning topics such as Python, Ruby, Scala, Go, JavaScript, Linux, open source software, the Web, and lesser-known programming languages.
Ad maiorem Dei gloriam inque hominum salutem.