{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/pxt/issues/2385","repository_url":"https://api.github.com/repos/Microsoft/pxt","labels_url":"https://api.github.com/repos/Microsoft/pxt/issues/2385/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/pxt/issues/2385/comments","events_url":"https://api.github.com/repos/Microsoft/pxt/issues/2385/events","html_url":"https://github.com/Microsoft/pxt/issues/2385","id":240036845,"number":2385,"title":"Pause in \"on start\" does not delay \"forever\" loops?","user":{"login":"microbit-carlos","id":29712657,"avatar_url":"https://avatars0.githubusercontent.com/u/29712657?v=4","gravatar_id":"","url":"https://api.github.com/users/microbit-carlos","html_url":"https://github.com/microbit-carlos","followers_url":"https://api.github.com/users/microbit-carlos/followers","following_url":"https://api.github.com/users/microbit-carlos/following{/other_user}","gists_url":"https://api.github.com/users/microbit-carlos/gists{/gist_id}","starred_url":"https://api.github.com/users/microbit-carlos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/microbit-carlos/subscriptions","organizations_url":"https://api.github.com/users/microbit-carlos/orgs","repos_url":"https://api.github.com/users/microbit-carlos/repos","events_url":"https://api.github.com/users/microbit-carlos/events{/privacy}","received_events_url":"https://api.github.com/users/microbit-carlos/received_events","type":"User","site_admin":false},"labels":[{"id":497111288,"url":"https://api.github.com/repos/Microsoft/pxt/labels/Microbit%20Foundation","name":"Microbit Foundation","color":"5319e7","default":false},{"id":412085282,"url":"https://api.github.com/repos/Microsoft/pxt/labels/P1","name":"P1","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2017-07-02T21:50:08Z","updated_at":"2017-09-14T09:29:03Z","closed_at":null,"author_association":"NONE","body":"microbit.org-ticket: 2187\r\n\r\nAren't the \"forever\" loops meant to start running after the \"on start\" blocks have finished?\r\n\r\nIf we need to initialise something before it can be used (like neopixels or game sprites), the \"on start\" is usually the preferred place to do that, but if the \"forever\" loops are declared before the \"on start\" code, and then the main fibre sleeps, you could have a race condition like in the following example:\r\n\r\n![microbit-screenshot](https://user-images.githubusercontent.com/29712657/27773713-e13ff006-5f77-11e7-8689-3b686d53e81d.png)\r\n\r\nThis program produces the following error and crashes the emulator:\r\n\r\n```\r\nProgram Error: r.isRef is not a function\r\n```\r\n\r\n\r\nHex file with this minimalist example: [issue.zip](https://github.com/Microsoft/pxt/files/1118125/issue.zip)\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/pxt/issues/comments/329427003","html_url":"https://github.com/Microsoft/pxt/issues/2385#issuecomment-329427003","issue_url":"https://api.github.com/repos/Microsoft/pxt/issues/2385","id":329427003,"user":{"login":"microbit-carlos","id":29712657,"avatar_url":"https://avatars0.githubusercontent.com/u/29712657?v=4","gravatar_id":"","url":"https://api.github.com/users/microbit-carlos","html_url":"https://github.com/microbit-carlos","followers_url":"https://api.github.com/users/microbit-carlos/followers","following_url":"https://api.github.com/users/microbit-carlos/following{/other_user}","gists_url":"https://api.github.com/users/microbit-carlos/gists{/gist_id}","starred_url":"https://api.github.com/users/microbit-carlos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/microbit-carlos/subscriptions","organizations_url":"https://api.github.com/users/microbit-carlos/orgs","repos_url":"https://api.github.com/users/microbit-carlos/repos","events_url":"https://api.github.com/users/microbit-carlos/events{/privacy}","received_events_url":"https://api.github.com/users/microbit-carlos/received_events","type":"User","site_admin":false},"created_at":"2017-09-14T09:29:03Z","updated_at":"2017-09-14T09:29:03Z","author_association":"NONE","body":"From my point of view having \"events\" like on shake or a button press execute before the \"on start\" finishes it's a valid expectation, as you could easily explain that you are triggering that event on micro:bit before it finishes execution that portion of the code.\r\nHowever, they way blocks like `forever` and `run in background` are named do no \"feel\" like events, in this case it is harder to explain the fiber model without introducing other concepts first, and why a pause will cause the other code to execute."}}
{"actor":{"display_login":"microbit-carlos"}}