Nullablity
Graydon Hoare
graydon at mozilla.com
Thu Jun 22 10:01:34 PDT 2006
Nicolas Cannasse wrote:
> As for values initialization, it should be enforced by the compiler.
> This can easily be done for member and local variables by using some
> recursive flow algorithm.
I know you're coming from the background of compiling large, highly
structured programs, and I respect that perspective. I personally agree
with what you've said here, in the context of a language *for my
programming needs*.
But I've also heard a credible argument during the design process: that
the majority of JS code on the web is tiny little fragments, one liners,
often fragments that only run zero or one times, and sometimes running
on a cell phone. Keeping the "defaults" easy to compile is a priority
for at least some of the language implementers. This means dataflow
algorithms are unappealing: local expression-type inference is about all
we want to pay for. We do not want to reimplement Java's definite
assignment rules or similar.
We've talked through many alternatives, and I agree that the topic is
not yet exhausted. Some syntactically distinct form that covers for the
same task is possible. We've discussed C++-style initializer syntax for
example, or ML-style construction-from-a-set-of-expressions. I'm sure
there are other potential options, but we must keep the tradeoffs in mind.
-graydon
More information about the Es4-discuss
mailing list