{"action":"created","issue":{"url":"https://api.github.com/repos/jhusain/compositional-functions/issues/3","labels_url":"https://api.github.com/repos/jhusain/compositional-functions/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/jhusain/compositional-functions/issues/3/comments","events_url":"https://api.github.com/repos/jhusain/compositional-functions/issues/3/events","html_url":"https://github.com/jhusain/compositional-functions/issues/3","id":74367083,"number":3,"title":"Advantages over yield and synchronous use cases","user":{"login":"benjamingr","id":1315533,"avatar_url":"https://avatars.githubusercontent.com/u/1315533?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamingr","html_url":"https://github.com/benjamingr","followers_url":"https://api.github.com/users/benjamingr/followers","following_url":"https://api.github.com/users/benjamingr/following{/other_user}","gists_url":"https://api.github.com/users/benjamingr/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamingr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamingr/subscriptions","organizations_url":"https://api.github.com/users/benjamingr/orgs","repos_url":"https://api.github.com/users/benjamingr/repos","events_url":"https://api.github.com/users/benjamingr/events{/privacy}","received_events_url":"https://api.github.com/users/benjamingr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-08T13:36:55Z","updated_at":"2015-05-12T15:50:31Z","closed_at":null,"body":"I think it would be really beneficial in this proposal to explain what this does that `yield` does not enable you to do at the moment. As is, why would you want compositional functions given you can already do this in not-so-bad syntax with yield. \r\n\r\nI think it might also be very beneficial to expand this proposal (without changing semantics) and explain how this can be used for arbitrary decorators. \r\n\r\nHere are some interesting use cases that can be implemented with compositional functions and enjoy this syntax. \r\n\r\n    class Foo {\r\n        observable foo(){\r\n             // converts any return value to an Observable.just and any thrown error to a rejected\r\n             // observable to guard against double try/catching \r\n        }\r\n        promise bar(){\r\n             // same idea but with promises, converts throws to rejections and returns to fulfillments\r\n        }\r\n        cached baz(){\r\n             // this method's return value is memoized\r\n        }\r\n        synchronised boo(){\r\n             // method returns a promise/task/observable and guarantees calls to underlying fn are queued \r\n        }\r\n        remote ban(){\r\n              // this method executes a remote procedure call to a server\r\n        }\r\n        async animal(){\r\n             // normal promise returning fn\r\n        }\r\n        logged cow(){\r\n            // every call to this method is logged\r\n        }\r\n        timed chicken(){\r\n             // this method is benchmarked\r\n        }\r\n        contract(x => !Number.isNaN(x) && x > 0) factorial(num){\r\n             // this contract is enforced in runtime\r\n        }\r\n        contract(Boolean) doSomethingToTruthy(){\r\n             // enforces truthy arg in runtime\r\n        }\r\n        contract(x => x., ret => ret instanceof Observable) thisAlwaysReturnsObservables(){\r\n            // enforces return value\r\n        }\r\n        autocurry add(x,y){\r\n              // automatically curried\r\n        }\r\n        compose(autocurry, observable, contract(Boolean) map(fn, val){\r\n            // returns a carried version of the map that allows awaiting observables\r\n            // and ensures a non-null argument is passed for fn\r\n        }\r\n        \r\n    }\r\n\r\nI think the fact we can get arbitrary decoration in class declarations and expressions should not be understated here and that there are a lot of interesting use cases to show.\r\n\r\nAlso, I wonder why not add `async` as a global which makes this proposal completely possible on top of the async/await one and can streamline it. \r\n    "},"comment":{"url":"https://api.github.com/repos/jhusain/compositional-functions/issues/comments/101328347","html_url":"https://github.com/jhusain/compositional-functions/issues/3#issuecomment-101328347","issue_url":"https://api.github.com/repos/jhusain/compositional-functions/issues/3","id":101328347,"user":{"login":"jhusain","id":466863,"avatar_url":"https://avatars.githubusercontent.com/u/466863?v=3","gravatar_id":"","url":"https://api.github.com/users/jhusain","html_url":"https://github.com/jhusain","followers_url":"https://api.github.com/users/jhusain/followers","following_url":"https://api.github.com/users/jhusain/following{/other_user}","gists_url":"https://api.github.com/users/jhusain/gists{/gist_id}","starred_url":"https://api.github.com/users/jhusain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhusain/subscriptions","organizations_url":"https://api.github.com/users/jhusain/orgs","repos_url":"https://api.github.com/users/jhusain/repos","events_url":"https://api.github.com/users/jhusain/events{/privacy}","received_events_url":"https://api.github.com/users/jhusain/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T15:50:31Z","updated_at":"2015-05-12T15:50:31Z","body":" It's definitely an option. I'm not sure how the committee will react to Allowing N modifiers on a function, and exactly what the implications on the parser would be. The most obvious downside would be allowing await in functions where it was not valid. "}}