{"action":"created","issue":{"url":"https://api.github.com/repos/perl11/cperl/issues/307","repository_url":"https://api.github.com/repos/perl11/cperl","labels_url":"https://api.github.com/repos/perl11/cperl/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/perl11/cperl/issues/307/comments","events_url":"https://api.github.com/repos/perl11/cperl/issues/307/events","html_url":"https://github.com/perl11/cperl/issues/307","id":243934747,"number":307,"title":"new enum type?","user":{"login":"rurban","id":41809,"avatar_url":"https://avatars2.githubusercontent.com/u/41809?v=4","gravatar_id":"","url":"https://api.github.com/users/rurban","html_url":"https://github.com/rurban","followers_url":"https://api.github.com/users/rurban/followers","following_url":"https://api.github.com/users/rurban/following{/other_user}","gists_url":"https://api.github.com/users/rurban/gists{/gist_id}","starred_url":"https://api.github.com/users/rurban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rurban/subscriptions","organizations_url":"https://api.github.com/users/rurban/orgs","repos_url":"https://api.github.com/users/rurban/repos","events_url":"https://api.github.com/users/rurban/events{/privacy}","received_events_url":"https://api.github.com/users/rurban/received_events","type":"User","site_admin":false},"labels":[{"id":256009805,"url":"https://api.github.com/repos/perl11/cperl/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-07-19T06:26:53Z","updated_at":"2017-07-19T07:55:47Z","closed_at":null,"body":"See https://docs.perl6.org/language/typesystem#index-entry-Enumeration-_Enums-_enum\r\nBasically constant typed arrays (Int or Str), starting with 0, with auto-incrementing values which can be overridden by using an optional pair syntax in the decl.\r\n\r\nThe current perl6 design is a bit *unfortunate* (i.e. broken), \r\nas stringified barewords don't return the value, but the name,\r\nand they look now like hashes, not arrays.\r\n`enum Names ( name1 => 1, name2 => 2 );`\r\n`say name1, ' ', name2; # OUTPUT: «name1 name2␤»`\r\nand you need to manually expand it: `say name1.value, ' ', name2.value; # OUTPUT: «1 2␤»`\r\nand not the other way round, as expected. They also say Number, not Int. (i.e. + Num, Rat. Wonder how to increment those).\r\n\r\nThe old design was correct: https://design.perl6.org/S12.html#Enumerations\r\nThat is,\r\n```\r\n     enum E <a b c>;\r\n```\r\nis largely syntactic sugar for:\r\n```\r\n     package E {\r\n        constant a = 0;\r\n        constant b = 1;\r\n        constant c = 2;\r\n    }\r\n```\r\n\r\nThe cperl plan is:\r\n```\r\nenum E (a b c);\r\nenum E1 (d => 1, e, f);  # but not the perl6 syntax: `enum E (:a(1), b c);` \r\nenum E2 (g, h => 4, i);  # pairs allowed everywhere \r\nprint a; # OUTPUT: «1»   but not «a»\r\n\r\nenum E3 (j => 1.0, k, l); # => error: Invalid enum type Num 1.0\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/perl11/cperl/issues/comments/316303250","html_url":"https://github.com/perl11/cperl/issues/307#issuecomment-316303250","issue_url":"https://api.github.com/repos/perl11/cperl/issues/307","id":316303250,"user":{"login":"rurban","id":41809,"avatar_url":"https://avatars2.githubusercontent.com/u/41809?v=4","gravatar_id":"","url":"https://api.github.com/users/rurban","html_url":"https://github.com/rurban","followers_url":"https://api.github.com/users/rurban/followers","following_url":"https://api.github.com/users/rurban/following{/other_user}","gists_url":"https://api.github.com/users/rurban/gists{/gist_id}","starred_url":"https://api.github.com/users/rurban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rurban/subscriptions","organizations_url":"https://api.github.com/users/rurban/orgs","repos_url":"https://api.github.com/users/rurban/repos","events_url":"https://api.github.com/users/rurban/events{/privacy}","received_events_url":"https://api.github.com/users/rurban/received_events","type":"User","site_admin":false},"created_at":"2017-07-19T07:55:47Z","updated_at":"2017-07-19T07:55:47Z","body":"No"}}
{"actor":{"display_login":"rurban"}}