-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
This issue was originally filed by [email protected]
Excerpt: http://www.dartlang.org/articles/optional-types/
If you love types, you may use them everywhere, much like in a statically typed language. However, even then you won’t get the same level of static checking. Dart’s rules are much less rigid. We anticipate providing additional tools that might interpret type annotations more strictly for those who like that sort of thing.
Problem code:
Object foo(){return "x";}
String s = foo();
This type of 'relaxed' type checking makes the type system almost useless. If you're going to implement static type checking, then at no point should it be acceptable to take a return value of type 'Object' and implicitly assume it might be a 'String'.
I can completely get behind making types optional. This should be done via the Dynamic keyword. Even you remark that "new List();" is just a shorthand for "new List<Dynamic>();" I can agree with a return value of type 'Dynamic' being assigned to a 'String' type without an error/warning.
Acceptable:
Dymanic foo(){ return "x";}
String s= foo();
Please implement strict static type checking before people start writing libraries. This would greatly appease those of us "... who like that sort of thing".