{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/2886","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2886/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2886/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2886/events","html_url":"https://github.com/crystal-lang/crystal/issues/2886","id":161418221,"number":2886,"title":"Literals for Slice(UInt8)","user":{"login":"asterite","id":209371,"avatar_url":"https://avatars0.githubusercontent.com/u/209371?v=4","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"labels":[{"id":260346999,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/status:draft","name":"status:draft","color":"00B8B8","default":false},{"id":253019637,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/topic:compiler","name":"topic:compiler","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":29,"created_at":"2016-06-21T12:00:41Z","updated_at":"2018-05-28T13:48:46Z","closed_at":"2018-05-28T13:17:50Z","author_association":"MEMBER","body":"We need a way to express binary data embedded in the data section of the program. We can do this right now for strings, but there's no way to create a non-UTF8 string with a string literal.\n\nThere are several ways we can fix this:\n1. We can add back the `\\x...` escape to string literals, to add a byte with a specific hexadecimal value. Right now strings can hold non-UTF8 data, they just raise when using those strings as UTF-8 data (for example, iterating them), so it's strange that they can hold non-UTF8 data but one can't create them with a literal. From there, one could take a slice. This will also solve #2565 because inspecting a string with non-valid codepoints will output `\\x...` for those values.\n2. We add a literal for something like a `Slice(UInt8)`. It could just be `Slice(UInt8)`, but these are not read-only. Or maybe they can be read-only and they can crash the program when written. One shouldn't write them, the same way as one doesn't get a slice from a string literal and writes to it. There was the idea of introducing `const [...]` for this, with which we could create static data for any kind of integer value.\n3. Other options...?\n\nThis doesn't have a big priority right now, but I'm leaving it here so there's a place to discuss this.\n"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/392531946","html_url":"https://github.com/crystal-lang/crystal/issues/2886#issuecomment-392531946","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2886","id":392531946,"user":{"login":"oprypin","id":371383,"avatar_url":"https://avatars3.githubusercontent.com/u/371383?v=4","gravatar_id":"","url":"https://api.github.com/users/oprypin","html_url":"https://github.com/oprypin","followers_url":"https://api.github.com/users/oprypin/followers","following_url":"https://api.github.com/users/oprypin/following{/other_user}","gists_url":"https://api.github.com/users/oprypin/gists{/gist_id}","starred_url":"https://api.github.com/users/oprypin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oprypin/subscriptions","organizations_url":"https://api.github.com/users/oprypin/orgs","repos_url":"https://api.github.com/users/oprypin/repos","events_url":"https://api.github.com/users/oprypin/events{/privacy}","received_events_url":"https://api.github.com/users/oprypin/received_events","type":"User","site_admin":false},"created_at":"2018-05-28T13:48:46Z","updated_at":"2018-05-28T13:48:46Z","author_association":"CONTRIBUTOR","body":"@RX14 Please reopen this"}}
{"actor":{"display_login":"oprypin"}}