{"action":"created","issue":{"url":"https://api.github.com/repos/perl6/doc/issues/2117","repository_url":"https://api.github.com/repos/perl6/doc","labels_url":"https://api.github.com/repos/perl6/doc/issues/2117/labels{/name}","comments_url":"https://api.github.com/repos/perl6/doc/issues/2117/comments","events_url":"https://api.github.com/repos/perl6/doc/issues/2117/events","html_url":"https://github.com/perl6/doc/issues/2117","id":334921063,"node_id":"MDU6SXNzdWUzMzQ5MjEwNjM=","number":2117,"title":"Create hashes with &hash","user":{"login":"Juerd","id":791835,"node_id":"MDQ6VXNlcjc5MTgzNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/791835?v=4","gravatar_id":"","url":"https://api.github.com/users/Juerd","html_url":"https://github.com/Juerd","followers_url":"https://api.github.com/users/Juerd/followers","following_url":"https://api.github.com/users/Juerd/following{/other_user}","gists_url":"https://api.github.com/users/Juerd/gists{/gist_id}","starred_url":"https://api.github.com/users/Juerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Juerd/subscriptions","organizations_url":"https://api.github.com/users/Juerd/orgs","repos_url":"https://api.github.com/users/Juerd/repos","events_url":"https://api.github.com/users/Juerd/events{/privacy}","received_events_url":"https://api.github.com/users/Juerd/received_events","type":"User","site_admin":false},"labels":[{"id":423513323,"node_id":"MDU6TGFiZWw0MjM1MTMzMjM=","url":"https://api.github.com/repos/perl6/doc/labels/meta","name":"meta","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-22T15:26:49Z","updated_at":"2018-06-23T03:40:00Z","closed_at":null,"author_association":"NONE","body":"## The problem\r\n\r\nThe [style guide](https://github.com/perl6/doc/blob/master/writing-docs/STYLEGUIDE.md) suggests using `{}` for empty hashes and `%()` for non-empty hashes. This is inconsistent.\r\n\r\n## Suggestions\r\n\r\nSince `{}` is considered confusing (although technically it's supposed to be straight forward) with blocks, and empty `%()` is considered a trap (see https://github.com/rakudo/rakudo/issues/1946), why not just use `hash` instead? According to jnthn in https://github.com/rakudo/rakudo/issues/1946#issuecomment-399396270 these are a \"sure bet\".\r\n\r\nSuggested: avoid both `%()` (empty construct is a trap) and `{}` (possible confusion with blocks) for constructing hashes, and always use `hash` instead:\r\n\r\n```\r\nmy $foo = hash;  # empty hash\r\nmy $bar = hash a => 'b', c => 'd';  # non-empty hash\r\n```\r\n\r\nNote: these can be used with or without parentheses. Since that goes for most expressions, that could probably use its own recommendation in the style guide."},"comment":{"url":"https://api.github.com/repos/perl6/doc/issues/comments/399627557","html_url":"https://github.com/perl6/doc/issues/2117#issuecomment-399627557","issue_url":"https://api.github.com/repos/perl6/doc/issues/2117","id":399627557,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTYyNzU1Nw==","user":{"login":"Juerd","id":791835,"node_id":"MDQ6VXNlcjc5MTgzNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/791835?v=4","gravatar_id":"","url":"https://api.github.com/users/Juerd","html_url":"https://github.com/Juerd","followers_url":"https://api.github.com/users/Juerd/followers","following_url":"https://api.github.com/users/Juerd/following{/other_user}","gists_url":"https://api.github.com/users/Juerd/gists{/gist_id}","starred_url":"https://api.github.com/users/Juerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Juerd/subscriptions","organizations_url":"https://api.github.com/users/Juerd/orgs","repos_url":"https://api.github.com/users/Juerd/repos","events_url":"https://api.github.com/users/Juerd/events{/privacy}","received_events_url":"https://api.github.com/users/Juerd/received_events","type":"User","site_admin":false},"created_at":"2018-06-23T03:40:00Z","updated_at":"2018-06-23T03:40:00Z","author_association":"NONE","body":"By the way, if the style guide does want to prescribe the use of `%(...)` for creating hashes, instead of `hash`, the following uses of `%(...)` with an Iterable of zero items seem to reliably return a new empty hash, unlike empty `%()`:\r\n\r\n```\r\n%(())\r\n%([])\r\n%({})  # lol\r\n%(Empty)\r\n```\r\n\r\nAnd then there are`%(Nil)`, `%(Any)`, and even `%(Int)`. I don't know why `Any.hash(Any:U:)` exists, but it enables a lot of new and confusing ways to create an empty hash. How about `%(X::Promise::CauseOnlyValidOnBroken)`? ;-)"}}
{"actor":{"display_login":"Juerd"}}