{"action":"created","issue":{"url":"https://api.github.com/repos/claudemr/entitysysd/issues/1","labels_url":"https://api.github.com/repos/claudemr/entitysysd/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/claudemr/entitysysd/issues/1/comments","events_url":"https://api.github.com/repos/claudemr/entitysysd/issues/1/events","html_url":"https://github.com/claudemr/entitysysd/issues/1","id":110357383,"number":1,"title":"Support const/immutable component fields","user":{"login":"rcorre","id":2496231,"avatar_url":"https://avatars.githubusercontent.com/u/2496231?v=3","gravatar_id":"","url":"https://api.github.com/users/rcorre","html_url":"https://github.com/rcorre","followers_url":"https://api.github.com/users/rcorre/followers","following_url":"https://api.github.com/users/rcorre/following{/other_user}","gists_url":"https://api.github.com/users/rcorre/gists{/gist_id}","starred_url":"https://api.github.com/users/rcorre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcorre/subscriptions","organizations_url":"https://api.github.com/users/rcorre/orgs","repos_url":"https://api.github.com/users/rcorre/repos","events_url":"https://api.github.com/users/rcorre/events{/privacy}","received_events_url":"https://api.github.com/users/rcorre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-08T02:04:53Z","updated_at":"2015-11-05T16:26:06Z","closed_at":null,"body":"Currently, component members cannot be const/immutable:\r\n\r\n    @component struct Thrust {\r\n        const float accel = 0f;\r\n        Vector2f direction = Vector2f(0,0);\r\n    }\r\n\r\n    entity.register!Thrust();\r\n\r\nThe above fails with:\r\n```\r\nentitysysd/entitysysd/pool.d(80,9): Error: cannot modify struct *this.getPtr(n) Thrust with immutable members\r\nentitysysd/entitysysd/entity.d(474,43): Error: template instance entitysysd.pool.Pool!(Thrust, 8192LU) error instantiating\r\nentitysysd/entitysysd/entity.d(142,34):        instantiated from here: register!(Thrust)\r\nsrc/app.d(178,42):        instantiated from here: register!(Thrust, )\r\n```\r\n\r\nLooking at how components are pooled, I'm not sure if there is a good way to do this without circumventing the type system, but it would be a nice feature to have."},"comment":{"url":"https://api.github.com/repos/claudemr/entitysysd/issues/comments/154111901","html_url":"https://github.com/claudemr/entitysysd/issues/1#issuecomment-154111901","issue_url":"https://api.github.com/repos/claudemr/entitysysd/issues/1","id":154111901,"user":{"login":"claudemr","id":6287908,"avatar_url":"https://avatars.githubusercontent.com/u/6287908?v=3","gravatar_id":"","url":"https://api.github.com/users/claudemr","html_url":"https://github.com/claudemr","followers_url":"https://api.github.com/users/claudemr/followers","following_url":"https://api.github.com/users/claudemr/following{/other_user}","gists_url":"https://api.github.com/users/claudemr/gists{/gist_id}","starred_url":"https://api.github.com/users/claudemr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudemr/subscriptions","organizations_url":"https://api.github.com/users/claudemr/orgs","repos_url":"https://api.github.com/users/claudemr/repos","events_url":"https://api.github.com/users/claudemr/events{/privacy}","received_events_url":"https://api.github.com/users/claudemr/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T16:26:06Z","updated_at":"2015-11-05T16:26:06Z","body":"Sorry for the late reply, you're right.\r\n\r\nIn a future version I'll allow to use \"const\" qualifier in component aggregates. The L-value opAssign will not be available in that case (it's what causes the error you mentioned). I'll also overload the register method with one that allow to initialise the component:\r\n```\r\n@component struct Thrust {\r\n    const float accel = 0f;\r\n    Vector2f direction = Vector2f(0,0);\r\n}\r\n\r\nThrust t;\r\n\r\nentity.register!Thrust(t);\r\n```\r\n\r\nHowever, I will prevent using the other qualifiers (immutable, shared or inout), for the reasons mentioned above."}}