{"action":"created","issue":{"url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/63","repository_url":"https://api.github.com/repos/cloudRoutine/issueCommRepo","labels_url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/63/comments","events_url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/63/events","html_url":"https://github.com/cloudRoutine/issueCommRepo/issues/63","id":182549729,"number":63,"title":"Code succinctness: Relax syntax rules for the else branch of an if expression (from Ada 2012)","user":{"login":"cloudRoutine","id":680051,"avatar_url":"https://avatars.githubusercontent.com/u/680051?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudRoutine","html_url":"https://github.com/cloudRoutine","followers_url":"https://api.github.com/users/cloudRoutine/followers","following_url":"https://api.github.com/users/cloudRoutine/following{/other_user}","gists_url":"https://api.github.com/users/cloudRoutine/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudRoutine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudRoutine/subscriptions","organizations_url":"https://api.github.com/users/cloudRoutine/orgs","repos_url":"https://api.github.com/users/cloudRoutine/repos","events_url":"https://api.github.com/users/cloudRoutine/events{/privacy}","received_events_url":"https://api.github.com/users/cloudRoutine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-12T15:02:13Z","updated_at":"2016-10-12T15:02:18Z","closed_at":null,"body":"# Code succinctness: Relax syntax rules for the else branch of an if expression (from Ada 2012) [12805656] #\n\n**Submitted by Anonymous on 3/4/2016 12:00:00 AM**  \n**[ 0 votes ]**  \n\nFor the sake of code succinctness, I suggest relaxing syntax rules for the else branch of an if expression in two special cases:\r\n1) When there is no else branch in an if expression and the type of the if expression is inferred to be bool, then the F# compiler should treat the absent else branch as equal to false, type bool (like in Ada 2012 for if expressions).\r\n2) When there is no else branch in an if expression and the type of the if expression is inferred to be option, then the compiler should treat the absent else branch as equal to None, type option.\r\nNow, when there is no else branch written in an if expression, the type of the absent else branch is inferred to be unit, and the F# compiler emits an error: FS0001: This expression was expected to have type unit but here has type... .\r\nNew syntax. Example # 1:\r\n[<Measure>]\r\ntype GBP\r\nlet status = false\r\n// money = None here\r\nlet money = if status then Some(100<GBP>)\r\nExample # 2:\r\nlet cashAvailable = false\r\nlet accountCorrect = true\r\n// status = false here due to cashAvailable = false\r\nlet status = if cashAvailable && accountCorrect then true\r\nelif not accountCorrect then false\r\nThese changes in the F# language syntax will not affect existing codebase. The if constructs with no else branch are allowed in Java, C#, Ada 2012, C++, VB.NET, just to name a few. I think this syntax will help remove an unnecessary burden from F# users (who have to write \"else false\", \"else None\" in their if expressions) and improve succinctness of F# code.\n\n"},"comment":{"url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/comments/253239415","html_url":"https://github.com/cloudRoutine/issueCommRepo/issues/63#issuecomment-253239415","issue_url":"https://api.github.com/repos/cloudRoutine/issueCommRepo/issues/63","id":253239415,"user":{"login":"cloudRoutine","id":680051,"avatar_url":"https://avatars.githubusercontent.com/u/680051?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudRoutine","html_url":"https://github.com/cloudRoutine","followers_url":"https://api.github.com/users/cloudRoutine/followers","following_url":"https://api.github.com/users/cloudRoutine/following{/other_user}","gists_url":"https://api.github.com/users/cloudRoutine/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudRoutine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudRoutine/subscriptions","organizations_url":"https://api.github.com/users/cloudRoutine/orgs","repos_url":"https://api.github.com/users/cloudRoutine/repos","events_url":"https://api.github.com/users/cloudRoutine/events{/privacy}","received_events_url":"https://api.github.com/users/cloudRoutine/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T15:02:18Z","updated_at":"2016-10-12T15:02:18Z","body":"### Posted by Charles on 3/6/2016 11:41:00 AM ###\nI like the existing unit default for imperative code.\r\nI don't see the value of defaulting to false for Boolean conditionals. Can't \"if a then b else false\" be rewritten as \"a and b\"?"}}
{"actor":{"display_login":"cloudRoutine"}}