{"action":"created","issue":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/626","repository_url":"https://api.github.com/repos/fsharp/fslang-suggestions","labels_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/626/labels{/name}","comments_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/626/comments","events_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/626/events","html_url":"https://github.com/fsharp/fslang-suggestions/issues/626","id":276554830,"number":626,"title":"Remove self binding in member declarations when not used: `member __.P = expr` > `member P = expr`","user":{"login":"alfonsogarciacaro","id":8275461,"avatar_url":"https://avatars0.githubusercontent.com/u/8275461?v=4","gravatar_id":"","url":"https://api.github.com/users/alfonsogarciacaro","html_url":"https://github.com/alfonsogarciacaro","followers_url":"https://api.github.com/users/alfonsogarciacaro/followers","following_url":"https://api.github.com/users/alfonsogarciacaro/following{/other_user}","gists_url":"https://api.github.com/users/alfonsogarciacaro/gists{/gist_id}","starred_url":"https://api.github.com/users/alfonsogarciacaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfonsogarciacaro/subscriptions","organizations_url":"https://api.github.com/users/alfonsogarciacaro/orgs","repos_url":"https://api.github.com/users/alfonsogarciacaro/repos","events_url":"https://api.github.com/users/alfonsogarciacaro/events{/privacy}","received_events_url":"https://api.github.com/users/alfonsogarciacaro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":27,"created_at":"2017-11-24T09:12:24Z","updated_at":"2017-11-29T20:46:26Z","closed_at":null,"author_association":"NONE","body":"I propose we make \"this\" binding optional in member declarations, so we get rid of the multiple `__.` (as in `member __.Foo() =`) in F# code. For reference see this comment from @vasily-kirichenko and the following four: https://github.com/fsharp/fslang-suggestions/issues/506#issuecomment-346688996\r\n\r\nInstead of:\r\n\r\n```fsharp\r\ng { new ICodeGen<ILCodeLabel> with\r\n      member __.CodeLabel(m) = m\r\n      member __.GenerateDelayMark() = generateCodeLabel()\r\n      member __.GenLocal(ilty) = failwith \"not needed\"\r\n      member __.SetMarkToHere(m) = lab2pc.[m] <- instrs.Count\r\n      member __.EmitInstr x = instrs.Add x\r\n      member cg.EmitInstrs xs = for i in xs do cg.EmitInstr i\r\n      member __.MkInvalidCastExnNewobj () = failwith \"not needed\" }\r\n```\r\n\r\nWe'd have:\r\n\r\n```fsharp\r\ng { new ICodeGen<ILCodeLabel> with\r\n      member CodeLabel(m) = m\r\n      member GenerateDelayMark() = generateCodeLabel()\r\n      member GenLocal(ilty) = failwith \"not needed\"\r\n      member SetMarkToHere(m) = lab2pc.[m] <- instrs.Count\r\n      member EmitInstr x = instrs.Add x\r\n      member cg.EmitInstrs xs = for i in xs do cg.EmitInstr i\r\n      member MkInvalidCastExnNewobj () = failwith \"not needed\" }\r\n```\r\n\r\nNOTE: This is only to remove the need of typing `__.` when there are no self references in the member body. It's not about implicitly binding `this`, in order to be able to self reference you would still need to bind `this` or any other identifier. The reasoning for this is [here](https://github.com/fsharp/fslang-suggestions/issues/506#issuecomment-346821054).\r\n\r\n## Pros\r\n\r\n- Cleaner syntax, it will likely make member declaration more uniform across code bases\r\n- Avoid users making a decision in advance whether to bind \"this\" or not\r\n- Avoid IDE warning when \"this\" binding is declared but is not used and is not `__`\r\n- Backwards compatible\r\n\r\n## Cons\r\n\r\n> Concerns by @dsyme in a comment below and [here](https://github.com/fsharp/fslang-suggestions/issues/506#issuecomment-346821054).\r\n\r\n1) Marginally less regular syntax - some instance members are member x.Method, some are member Method.\r\n2) As a result it probably marginally disincentives the use of member x.Method bindings in F# methods - people might feel they are doing something wrong, when in fact it's pretty normal and reasonable to use member x.Method in members.\r\n3) Property can be declared as `member x.P = expr`. Some programmers - especially those from ML-family languages - would take a while to grok that expr was evaluated once on each property use. We assessed that confusion on this point would be more likely with syntax `member P = expr`.\r\n\r\n> Note by me: For 1) if IDEs remove the current exception for `__.` for the \"Not used value\" (which afaik is only a convention), hopefully there would be a transition period and then people will just get used to delete `__.` or `x.` when not used to remove the warning. About 3) properties in .NET are very convenient but make it easier to forget the expression is evaluated in every use, no matter if it's C# or F#, I think this is a tradeoff programmers need to be aware of.\r\n\r\n## Extra information\r\n\r\nEstimated cost (XS, S, M, L, XL, XXL): I guess it will affect mainly parsing and IDE tooling but I'm not sure how difficult to support the new syntax\r\n\r\n## Affidavit (please submit!)\r\n\r\nPlease tick this by placing a cross in the box:\r\n* [x] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue\r\n* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate\r\n* [x] This is not something which has obviously \"already been decided\" in previous versions of F#.  If you're questioning a fundamental design decision that has obviously already been taken (e.g. \"Make F# untyped\") then please don't submit it.\r\n\r\nPlease tick all that apply:\r\n* [x] This is not a breaking change to the F# language design\r\n* [x] I or my company would be willing to help implement and/or test this\r\n"},"comment":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/comments/347990880","html_url":"https://github.com/fsharp/fslang-suggestions/issues/626#issuecomment-347990880","issue_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/626","id":347990880,"user":{"login":"vasily-kirichenko","id":873919,"avatar_url":"https://avatars2.githubusercontent.com/u/873919?v=4","gravatar_id":"","url":"https://api.github.com/users/vasily-kirichenko","html_url":"https://github.com/vasily-kirichenko","followers_url":"https://api.github.com/users/vasily-kirichenko/followers","following_url":"https://api.github.com/users/vasily-kirichenko/following{/other_user}","gists_url":"https://api.github.com/users/vasily-kirichenko/gists{/gist_id}","starred_url":"https://api.github.com/users/vasily-kirichenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasily-kirichenko/subscriptions","organizations_url":"https://api.github.com/users/vasily-kirichenko/orgs","repos_url":"https://api.github.com/users/vasily-kirichenko/repos","events_url":"https://api.github.com/users/vasily-kirichenko/events{/privacy}","received_events_url":"https://api.github.com/users/vasily-kirichenko/received_events","type":"User","site_admin":false},"created_at":"2017-11-29T20:46:26Z","updated_at":"2017-11-29T20:46:26Z","author_association":"NONE","body":"I love the explicit way Microsoft avoid improving the language based on the users feedback 👍 \"If you really need a feature (Microsoft itself do not, never), go implement it\""}}
{"actor":{"display_login":"vasily-kirichenko"}}