[dart-announce] BREAKING CHANGE: dart:io Platform and Options are deprecated, and will be removed

259 views
Skip to first unread message

William Hesse

unread,
Oct 25, 2013, 3:10:13 PM10/25/13
to announce
What Changes?

The classes Platform and Options will be removed from dart:io, since they are replaced by the new dart:platform library, available on all Dart platforms.

The arguments to a Dart script, Options.arguments, are replaced by the optional arguments parameter of main: main(List<String> arguments).
The static getters of Platform are top-level getters in dart:platform, with the same values as in dart:io.  The fields isWindows, isLinux, isMacOS, and isAndroid have
been removed, and script has been changed from a String containing a native filesystem path to a file Uri.

How do I update my code?

Import the dart:platform library, possibly as a named import, like

import 'dart:platform' as platform;

and use platform where you previously had Platform, or using show, as in

import 'dart:platform' show operatingSystem;


Replace Platform.script with platform.script.toFilePath(), or use platform.script as a Uri.
Replace isWindows with platform.operatingSystem == 'windows', and similarly with 'linux',
'macos', and 'android'.

Why did this change happen?

The arguments parameter was added to main, removing the last use of Options, and the system information provided by dart:io Platform was thought to be useful on all platforms, not just those
supporting dart:io, so a dart:platform library was added containing this information.

When will the change take effect?

The new dart:platform library is already available on bleeding-edge Dart, as is main(List<String> arguments).  The old classes will be removed around November 1st, 2013.


--
For more news and information, visit http://news.dartlang.org/
 
To join the conversation, visit https://groups.google.com/a/dartlang.org/

Sean Eagan

unread,
Oct 25, 2013, 3:50:40 PM10/25/13
to General Dart Discussion
Love this change!

But I feel `arguments` should be in 'dart:platform', not as an argument to main.  It feels inconsistent that it's not there alongside all the other command line info such as `script`, `executable`, `executableArguments`.  And it's quite inconvenient to have to recursively pass it from main down to any code that needs it.

Is there some advantage of having it as an argument to main that I am missing?

Cheers,
Sean Eagan


--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Jos Hirth

unread,
Oct 25, 2013, 5:18:12 PM10/25/13
to mi...@dartlang.org
On Friday, October 25, 2013 9:50:40 PM UTC+2, Sean Eagan wrote:

Is there some advantage of having it as an argument to main that I am missing?

It's what most people expect. The arguments are passed to main in C, C++, Java, C#, D, and the like.

When I tried to use command line arguments, this what was I tried first.

William Hesse

unread,
Oct 28, 2013, 12:58:44 PM10/28/13
to announce, General Dart Discussion
The new dart:platform library, and the removal of dart:io Platform, are not completely decided on yet, and may be changed in the next few days, so I would recommend against porting your code to dart:platform right now - we may change it, and/or leave some properties in dart:io.
William Hesse

William Hesse

unread,
Oct 29, 2013, 5:22:48 AM10/29/13
to announce, General Dart Discussion
We have decided against creating the dart:platform library at the present time.  We don't have consensus on what should be in it, what its interface should look like, and if it is the best way to accomplish what we want.  So the library will be removed, effective immediately.

One of the changes, to the "script" field, will be done in the dart:io Platform class: Platform.script will be made a URI, not a String containing a native filesystem path.
dart:io's Options class remains deprecated and will be removed very soon.

A new Breaking Change message will also be sent out with this information.

We welcome discussion about how to make information about the platform a Dart program is running on available, and what information should be exposed.  This should be in a separate thread, though.
William Hesse
Reply all
Reply to author
Forward
0 new messages