{"action":"created","issue":{"url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/62","labels_url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/62/comments","events_url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/62/events","html_url":"https://github.com/jayfor-lang/jayfor/issues/62","id":54122428,"number":62,"title":"Proposal: Functions that belong to a structure","user":{"login":"freefouran","id":6254332,"avatar_url":"https://avatars.githubusercontent.com/u/6254332?v=3","gravatar_id":"","url":"https://api.github.com/users/freefouran","html_url":"https://github.com/freefouran","followers_url":"https://api.github.com/users/freefouran/followers","following_url":"https://api.github.com/users/freefouran/following{/other_user}","gists_url":"https://api.github.com/users/freefouran/gists{/gist_id}","starred_url":"https://api.github.com/users/freefouran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freefouran/subscriptions","organizations_url":"https://api.github.com/users/freefouran/orgs","repos_url":"https://api.github.com/users/freefouran/repos","events_url":"https://api.github.com/users/freefouran/events{/privacy}","received_events_url":"https://api.github.com/users/freefouran/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jayfor-lang/jayfor/labels/proposal","name":"proposal","color":"adbeef"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":43,"created_at":"2015-01-12T23:25:59Z","updated_at":"2015-01-13T10:23:16Z","closed_at":null,"body":"We were going to use `impl`, like Rust:\r\n\r\n```\r\nstruct whatever {\r\n    int x;\r\n};\r\n\r\nimpl whatever {\r\n    fn construct(whatever 'self) {\r\n        self.x = 5;\r\n    }\r\n}\r\n```\r\nHowever, I've been looking at go recently, and I like how they do it:\r\n```\r\n// struct called Whatever\r\n// i could be wrong with this since I haven't written any Go before\r\nfunc (w Whatever) thingy(name string) {\r\n    w.name = name\r\n}\r\n```\r\nSo perhaps we could define what struct the function belongs to, a syntax idea of mine:\r\n```\r\nstruct person {\r\n    int age;\r\n    string name;\r\n};\r\n\r\n// some syntax ideas\r\nfn (person p) set_name(string name): void {\r\n    p.name = name;\r\n}\r\n\r\nfn [person p] set_name(string name): void {\r\n    p.name = name;\r\n}\r\n\r\n// this ones kinda weird\r\nfn set_name(string name): void {|person p|\r\n    p.name = name;\r\n}\r\n\r\nfn set_name[Person p](string name): void {\r\n    p.name = name;\r\n}\r\n\r\n// Perhaps just having [Person] is shorthand for [Person self]\r\nfn set_name[Person](string name): void {\r\n    self.name = name;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/comments/69723773","html_url":"https://github.com/jayfor-lang/jayfor/issues/62#issuecomment-69723773","issue_url":"https://api.github.com/repos/jayfor-lang/jayfor/issues/62","id":69723773,"user":{"login":"CaptainChloride","id":7758442,"avatar_url":"https://avatars.githubusercontent.com/u/7758442?v=3","gravatar_id":"","url":"https://api.github.com/users/CaptainChloride","html_url":"https://github.com/CaptainChloride","followers_url":"https://api.github.com/users/CaptainChloride/followers","following_url":"https://api.github.com/users/CaptainChloride/following{/other_user}","gists_url":"https://api.github.com/users/CaptainChloride/gists{/gist_id}","starred_url":"https://api.github.com/users/CaptainChloride/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CaptainChloride/subscriptions","organizations_url":"https://api.github.com/users/CaptainChloride/orgs","repos_url":"https://api.github.com/users/CaptainChloride/repos","events_url":"https://api.github.com/users/CaptainChloride/events{/privacy}","received_events_url":"https://api.github.com/users/CaptainChloride/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T10:23:16Z","updated_at":"2015-01-13T10:23:16Z","body":"kkkkkk"}}