{"action":"created","issue":{"url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/13","repository_url":"https://api.github.com/repos/samuelgoto/proposal-block-params","labels_url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/13/comments","events_url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/13/events","html_url":"https://github.com/samuelgoto/proposal-block-params/issues/13","id":269374300,"number":13,"title":"`with`-like performance concerns","user":{"login":"isiahmeadows","id":4483844,"avatar_url":"https://avatars1.githubusercontent.com/u/4483844?v=4","gravatar_id":"","url":"https://api.github.com/users/isiahmeadows","html_url":"https://github.com/isiahmeadows","followers_url":"https://api.github.com/users/isiahmeadows/followers","following_url":"https://api.github.com/users/isiahmeadows/following{/other_user}","gists_url":"https://api.github.com/users/isiahmeadows/gists{/gist_id}","starred_url":"https://api.github.com/users/isiahmeadows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isiahmeadows/subscriptions","organizations_url":"https://api.github.com/users/isiahmeadows/orgs","repos_url":"https://api.github.com/users/isiahmeadows/repos","events_url":"https://api.github.com/users/isiahmeadows/events{/privacy}","received_events_url":"https://api.github.com/users/isiahmeadows/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-10-29T06:08:43Z","updated_at":"2017-11-01T07:59:40Z","closed_at":null,"author_association":"NONE","body":"The implicit `this` binding spurs some `with`-related performance concerns. The callback body could, in sloppy mode, be desugared almost precisely to this:\r\n\r\n```js\r\nwith (typeof x === \"object\" && x != null ? x : Object.create(null)) {\r\n    // body\r\n}\r\n```\r\n\r\nFor well-known reasons at this point, engines have severely struggled to optimize `with`, and I suspect they'll have similar objections to this.\r\n\r\n-----\r\n\r\nHere's a few potential solutions:\r\n\r\n- If a local binding does *not* exist, *then* fall back to the `with`-like behavior. Engines can continue to optimize existing variable accesses, deferring the scope check to globals vs `this` (which already requires an unavoidable runtime check)\r\n\r\n- Require some sort of prefix/sigil like either one of these (or something completely different altogether):\r\n\r\n    ```js\r\n    server(app) {\r\n        ::get(\"/route\") { ... }\r\n    }\r\n\r\n    server(app) {\r\n        @get(\"/route\") { ... }\r\n    }\r\n    ```\r\n\r\n    (Note: the second does *not* conflict with decorators, since you can't \"decorate\" blocks.)\r\n\r\n- Drop the implicit `this` binding in nested blocks altogether and just require users to use `this.foo`."},"comment":{"url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/comments/341027468","html_url":"https://github.com/samuelgoto/proposal-block-params/issues/13#issuecomment-341027468","issue_url":"https://api.github.com/repos/samuelgoto/proposal-block-params/issues/13","id":341027468,"user":{"login":"isiahmeadows","id":4483844,"avatar_url":"https://avatars1.githubusercontent.com/u/4483844?v=4","gravatar_id":"","url":"https://api.github.com/users/isiahmeadows","html_url":"https://github.com/isiahmeadows","followers_url":"https://api.github.com/users/isiahmeadows/followers","following_url":"https://api.github.com/users/isiahmeadows/following{/other_user}","gists_url":"https://api.github.com/users/isiahmeadows/gists{/gist_id}","starred_url":"https://api.github.com/users/isiahmeadows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isiahmeadows/subscriptions","organizations_url":"https://api.github.com/users/isiahmeadows/orgs","repos_url":"https://api.github.com/users/isiahmeadows/repos","events_url":"https://api.github.com/users/isiahmeadows/events{/privacy}","received_events_url":"https://api.github.com/users/isiahmeadows/received_events","type":"User","site_admin":false},"created_at":"2017-11-01T07:59:40Z","updated_at":"2017-11-01T07:59:40Z","author_association":"NONE","body":"> If this.app is not defined, it is equivalent to let a = undefined; a();.\r\n>\r\n> That is, it throws.\r\n\r\nOkay, that works as expected.\r\n\r\n> Ah, good point about nesting DSLs. A couple of options:\r\n>\r\n> 1) The nested DSL uses the binding operator: e.g. ::render(elem) {}\r\n> 2) The nested DSL somehow registers with the outer DSL. e.g. @component\r\n> class MyElement extends React.Component { ... } with annotations.\r\n\r\nI'd *strongly* prefer the first option (independent of syntax) with nesting DSLs, since it avoids making the outer DSL's responsibility to make sure it gets invoked correctly.\r\n\r\nAlso, for consistency and reduced confusion, we *should* require that top-level DSLs also use the same operator nested DSLs use. That way, it's 1. clear you're using a DSL and not just plain JS, and 2. there's only one syntax."}}
{"actor":{"display_login":"isiahmeadows"}}