Reputation: 11210
There seem to be some special classes in Dart such as num
, that cannot be normally inherited by user-defined classes, although there is nothing in the Dart syntax itself which prevents it (such as Java's final
or C#'s sealed
). num
is inherited by the built-in int
and double
, though.
Upvotes: 3
Views: 1046
Reputation: 11210
Here is an official answer on similar question from Dart Team that was found on https://code.google.com/p/dart/issues/list.
Gilad Bracha said on this occasion:
You could almost think of int, double, bool, Null and String as final classes in Java (num doesn't fit that mold as it has subtypes). By design, we don't support final classes, to minimize complexity and avoid code where you cannot subclass (much as the submitter wants). Instead of final classes, we chose to have list of types that cannot be extended.
Why: because these are critical for efficiency. Its not a very purist argument, but pragmatically most people would trade the flexibility for a faster system.
++++++++
RE: Comment from me: It's really not a very purist argument because this not helps make language clearer and better in the end.
++++++++
Also this is not out of context words, but this is the official position of Jun 29, 2012.
Maybe today there is another interpretation from the Dart Team, but it will be available only from the official response to the questions raised.
P.S.
Tnanks to ringstaff for the link to this answer.
P.S.
Please leave your comments on this official position if you want make Dart language clearer and better.
In an afterword:
Upvotes: 2