2 ms·
If you allowed top-level imperative code to mix with non-imperative definitions, it gets really semantically squishy. Top-level variables in Dart are lazy-initi
by munificent 13y ago
If you allowed top-level imperative code to mix with non-imperative definitions, it gets really semantically squishy. Top-level variables in Dart are lazy-initialized, which lets their order not matter. But variables in imperative code are initialized at definition time. How does the language tell which one it should prefer if it allows both at the top level?
Also, if you import a library that contains this top-level imperative code, how do you invoke it? Is it invoked automatically? When? How does that play with cyclic imports?
The small amount of overhead of a main() method solves all of that.