PSA - Breaking Change in Dart main signature

8 views
Skip to first unread message

Florian Loitsch

unread,
Feb 29, 2016, 10:47:44 AM2/29/16
to mojo-dev
Hi all,
starting with commit 2738f1b76f9edf11de0dea5d6caef6e9beec0707, Dart Mojo applications have to change their `main` function.

What changed?:
Before, the Mojo parameters were given in the `arguments` object:
main(arguments) {
  arguments[0] => Mojo handle
  arguments[1] => URI
  arguments[2] => original arguments array.
}

After the change the additional parameters are in the extra message parameter slot, and in Uri.base:

main(arguments, Object mojoHandle) {
  var uri = Uri.base;
}

Sidenote: I recommend not to type the mojo-handle as integer.

Why?:
This aligns the main signature of Mojo applications with the standard main signature. In particular, the `List<String> arguments` parameter is not actually a list of Strings, and represents the arguments that were given to the application.

When:
this change has been committed to the repository: #2738f1b76f9edf11de0dea5d6caef6e9beec0707

// florian

James Robinson

unread,
Feb 29, 2016, 1:11:30 PM2/29/16
to Florian Loitsch, mojo-dev
On Mon, Feb 29, 2016 at 7:47 AM, 'Florian Loitsch' via mojo-dev <mojo...@chromium.org> wrote:

Sidenote: I recommend not to type the mojo-handle as integer.

Could you explain the reason behind this sidenote?

- James

Florian Loitsch

unread,
Feb 29, 2016, 1:39:34 PM2/29/16
to James Robinson, mojo-dev
Two reasons:
- in the Dart-standalone (not Mojo shell) version, the handle is not an integer.
- unless you need to do integer operations with the handle, there is no need to type it as int. Ideally it should be a typedef, but we don't have those in Dart (yet). Typing it as 'int' makes it harder to do changes in the future. It could be interesting to track handles differently (and if it's just to be able to use them in Expandos), but that wouldn't be possible if users typed the handles as 'int's.

- James
Reply all
Reply to author
Forward
0 new messages