{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/9","labels_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/9/comments","events_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/9/events","html_url":"https://github.com/tc39/ecmascript-asyncawait/issues/9","id":30445680,"number":9,"title":"Clarifying question: can await be used in top-level code?","user":{"login":"davidbau","id":3458792,"avatar_url":"https://avatars.githubusercontent.com/u/3458792?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbau","html_url":"https://github.com/davidbau","followers_url":"https://api.github.com/users/davidbau/followers","following_url":"https://api.github.com/users/davidbau/following{/other_user}","gists_url":"https://api.github.com/users/davidbau/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbau/subscriptions","organizations_url":"https://api.github.com/users/davidbau/orgs","repos_url":"https://api.github.com/users/davidbau/repos","events_url":"https://api.github.com/users/davidbau/events{/privacy}","received_events_url":"https://api.github.com/users/davidbau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2014-03-29T15:18:22Z","updated_at":"2015-04-09T19:26:48Z","closed_at":null,"body":"In the proposal, it looks like \"await\" is to be used inside async functions.\r\n\r\nCan \"await\" be used in top-level code?\r\n\r\nThe reason is, when teaching students, it makes a lot of sense to start with top-level code that does not contain function definitions, and it also makes sense to \"await input\", such as in this example using Iced CoffeeScript's \"await\".  What would this example look like in this proposal?\r\n\r\nhttp://pencilcode.net/edit/guessmynumber\r\n"},"comment":{"url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/comments/91333930","html_url":"https://github.com/tc39/ecmascript-asyncawait/issues/9#issuecomment-91333930","issue_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/9","id":91333930,"user":{"login":"getify","id":150330,"avatar_url":"https://avatars.githubusercontent.com/u/150330?v=3","gravatar_id":"","url":"https://api.github.com/users/getify","html_url":"https://github.com/getify","followers_url":"https://api.github.com/users/getify/followers","following_url":"https://api.github.com/users/getify/following{/other_user}","gists_url":"https://api.github.com/users/getify/gists{/gist_id}","starred_url":"https://api.github.com/users/getify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getify/subscriptions","organizations_url":"https://api.github.com/users/getify/orgs","repos_url":"https://api.github.com/users/getify/repos","events_url":"https://api.github.com/users/getify/events{/privacy}","received_events_url":"https://api.github.com/users/getify/received_events","type":"User","site_admin":false},"created_at":"2015-04-09T19:26:48Z","updated_at":"2015-04-09T19:26:48Z","body":"> include an informative note on (1) that REPL's should aim to support `await` at top-level\r\n\r\nMy objection was to including a note, and specifically to including a note (even a non-normative one) that says \"should\". If the spec doesn't aim to provide any guidance on *how* (for REPLs), then it shouldn't aim to provide any guidance on *what* (for REPLs) either. If a REPL wants to try it, having such a non-normative note in there isn't going to sway them one direction or the other.\r\n\r\n-----\r\n\r\nDespite the assertion \"the entire REPL should be a module\", that's not in any way reflective of any real world requirement (or even present/near-future reality). Some REPLs will, I'm sure, but others won't. \r\n\r\nOne problem with making a REPL session a module is that modules don't have access to the global scope, and yet many developers do in fact use things like the dev console's \"REPL\" to interact with the global scope. Same goes with interactive debugging sessions. Also, if a REPL has an `await` (or any other blocking mechanism, like `import`) in it, and the user types it in and it fires off a long running process, will that REPL just sit there appearing to be hung? I'm skeptical there really will be that many REPLs which go that direction, if for no other reason but UX.\r\n\r\nMy only point is that it's in no way a foregone conclusion that all or even most REPLs will significantly differ from main scripts in terms of how they deal with top-level asynchrony (blocking, etc). Since this spec doesn't want to tackle that beast, it should remain silent on the topic altogether."}}