All these changes are welcomed! I second Matt's request that, when possible, they be accompanied by a "this change will occur as of build x" statement.
On Monday, September 17, 2012 5:19:30 AM UTC-3, Lasse Reichstein Holst Nielsen wrote:Greetings all.We are removing parseInt and parseDouble from the dart:math library, and making them static methods called "parse" on the int and double classes.The original reason, from long ago, for putting them in Math was that int and double were interfaces, and couldn't contain static methods. Now that we are converting all interfaces to abstract classes, we will move those functions where they belong.The dart:math parseInt/parseDouble functions will still work, but they will be removed in about a week.The functions now have documentation too! Please do report if it is confusing or misleading in any way.Cheers/L
What build does the new syntax start working? I'm using 12144 and the method signature exists, however when I try to use int.parseInt('42'); I get Unresolved static method 'parseInt'
The change was committed in revision 12417, so it should be available.The new functions are called just "parse", so try int.parse('42') instead.
And duly noted: I'll try to give the revision number of changes in the future when posting about changes after the fact.
Cheers!/L--Lasse R.H. Nielsen - l...@google.com'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84
> Lasse, one question: Why make "parse()" static methods and not named constructors?
Exactly. Other classes use the 'fromString' constructor and while I'd love it to be called 'parse', it should still be a constructor.
LT
> Lasse, one question: Why make "parse()" static methods and not named constructors?Exactly. Other classes use the 'fromString' constructor and while I'd love it to be called 'parse', it should still be a constructor.
Also, currently the only way to check if a string is a number literal is to call parse and see if it throws (but I'm not entirely satisfied with that!), and I don't like constructors that throw on anything but programming errors.
On Tue, Sep 18, 2012 at 3:07 AM, Lasse R.H. Nielsen <l...@google.com> wrote:Also, currently the only way to check if a string is a number literal is to call parse and see if it throws (but I'm not entirely satisfied with that!), and I don't like constructors that throw on anything but programming errors.I agree it would be more convenient to have them return null instead of throw, and it would be strange if a constructor ever returned null.A couple questions:Why double.parse instead of num.parse ? I think double.parse would encourage people to use "double" as a type annotation which according to the style guide is bad.
Sean EaganIt looks like (see http://dartbug.com/233) there is a plan for int.parseRadix (num/double.parseRadix too ?), why not just use an optional radix parameter ?
Also, I assume "package:intl" will contain something like:NumFormatIntFormatIf so, then why do we need any of the following:int.parseint.parseRadixdouble.parsenum.toRadixStringnum.toStringAsExponentialnum.toStringAsFixednum.toStringAsPrecisionOne reason is because placing this functionality in a "dart:" library allows it to be optimized to native JavaScript/C++, but it could be changed to "dart:intl", which would also allow it to use pre-installed localization data (only in the VM for now, but also in dart2js when browsers support the EcmaScript Internationalization API) instead of having to download it over HTTP at runtime.Cheers,
--
On Tue, Sep 18, 2012 at 3:07 AM, Lasse R.H. Nielsen <l...@google.com> wrote:Also, currently the only way to check if a string is a number literal is to call parse and see if it throws (but I'm not entirely satisfied with that!), and I don't like constructors that throw on anything but programming errors.I agree it would be more convenient to have them return null instead of throw, and it would be strange if a constructor ever returned null.
--
--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
Corresponding Clean-Up was added to the Editor (continuous build, not in integration yet).
Konstantin ScheglovSoftware EngineerGoogle, Inc.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new