User:Colby Russell/Static initializers: Difference between revisions

m
fix list formatting
(ordering concerns for static initializers)
m (fix list formatting)
Line 42:
NB: There are also ordering concerns, similar to those we ran into for <code>extends</code>, based on TC39's (IMO extremely silly and unnecessary) decision to make class hoisting differ from the way function hoisting works. This means we have some difficult choices:
 
1.# forbid cross-module references for top-level scope (no <code>Scanner.WHITESPACE = Token.WHITESPACE</code>, for example; we could make an exception for where we're already handling ordering issues, such as if <code>A</code> extends <code>B</code>, then <code>A.FOO = B.BAR</code> is permitted, but that seems sketchy)
2.# forbid them as above, but give static assertions special powers and by necessity sequester parsing issues with the mandate that they appear only as a triple slash directives
3.# allow everything forbidden in (1), so long as there's a way to do re-ordering that eliminates the problem, and then have the compiler do it
 
Of these choices, I like (3) the least, because it also compromises our principle of "you can keep all the rules in your head, and whatever the compiler does you could do yourself by hand if you wanted to" and it leads to code that isn't [[top-down]]. And I don't especially look forward to having to implement a satisfiability solver even in the compiler.