{"action":"created","issue":{"url":"https://api.github.com/repos/rakudo/rakudo/issues/426","labels_url":"https://api.github.com/repos/rakudo/rakudo/issues/426/labels{/name}","comments_url":"https://api.github.com/repos/rakudo/rakudo/issues/426/comments","events_url":"https://api.github.com/repos/rakudo/rakudo/issues/426/events","html_url":"https://github.com/rakudo/rakudo/pull/426","id":76100505,"number":426,"title":"Add support for additional mode flags to IO::Handle.open","user":{"login":"cygx","id":11423773,"avatar_url":"https://avatars.githubusercontent.com/u/11423773?v=3","gravatar_id":"","url":"https://api.github.com/users/cygx","html_url":"https://github.com/cygx","followers_url":"https://api.github.com/users/cygx/followers","following_url":"https://api.github.com/users/cygx/following{/other_user}","gists_url":"https://api.github.com/users/cygx/gists{/gist_id}","starred_url":"https://api.github.com/users/cygx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygx/subscriptions","organizations_url":"https://api.github.com/users/cygx/orgs","repos_url":"https://api.github.com/users/cygx/repos","events_url":"https://api.github.com/users/cygx/events{/privacy}","received_events_url":"https://api.github.com/users/cygx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-13T19:41:18Z","updated_at":"2015-05-13T21:30:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rakudo/rakudo/pulls/426","html_url":"https://github.com/rakudo/rakudo/pull/426","diff_url":"https://github.com/rakudo/rakudo/pull/426.diff","patch_url":"https://github.com/rakudo/rakudo/pull/426.patch"},"body":"In addition to `:r`, `:w`, `:a` and the (previously ignored) `:rw`, there's now also `:ra`, `:wx`, `:wr`, `:wrx`, `:ar`.\r\n\r\nWith the exception of `:ra` (added for consistency), these correspond to the modes of `fopen()` as specified by C11 - you get to the Perl6 name by replacing `+` with `r` or `w` as appropriate.\r\n\r\nThe `$llmode` parameter to the private `!open` method translates directly to POSIX flags:\r\n\r\n    r  O_RDONLY\r\n    -  O_WRONLY\r\n    +  O_RDWR\r\n    a  O_APPEND\r\n    c  O_CREAT\r\n    x  O_EXCL\r\n    t  O_TRUNC\r\n\r\n`w` is a special compatibility alias that translates to `-ct` on its own and to `-c` as part of a string. This ensures that `w` and `wa` still map to their expected values.\r\n\r\nAdding Perl5 into the mix, we end up with the following:\r\n\r\n    p6      c11     moar    compat  p5\r\n    ************************************\r\n    :r      r       r               <\r\n    :rw     r+      +               +<\r\n    :ra             +a\r\n    :w      w       -ct     w       >\r\n    :wx     wx      -cx     wx\r\n    :wr     w+      +ct             +>\r\n    :wrx    w+x     +cx\r\n    :a      a       -ca     wa      >>\r\n    :ar     a+      +ca             +>>\r\n\r\nOn the JVM, unsupported modes will blow up, but everything that used to work should continue to work (with the caveat that `:rw` now blows up instead of silently getting adjusted to `:w`).\r\n\r\nOn Parrot, unsupported modes will lead to undefined behaviour as unknown characters get silently dropped from mode strings."},"comment":{"url":"https://api.github.com/repos/rakudo/rakudo/issues/comments/101821973","html_url":"https://github.com/rakudo/rakudo/pull/426#issuecomment-101821973","issue_url":"https://api.github.com/repos/rakudo/rakudo/issues/426","id":101821973,"user":{"login":"cygx","id":11423773,"avatar_url":"https://avatars.githubusercontent.com/u/11423773?v=3","gravatar_id":"","url":"https://api.github.com/users/cygx","html_url":"https://github.com/cygx","followers_url":"https://api.github.com/users/cygx/followers","following_url":"https://api.github.com/users/cygx/following{/other_user}","gists_url":"https://api.github.com/users/cygx/gists{/gist_id}","starred_url":"https://api.github.com/users/cygx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygx/subscriptions","organizations_url":"https://api.github.com/users/cygx/orgs","repos_url":"https://api.github.com/users/cygx/repos","events_url":"https://api.github.com/users/cygx/events{/privacy}","received_events_url":"https://api.github.com/users/cygx/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T21:30:23Z","updated_at":"2015-05-13T21:30:23Z","body":"@donaldh That's certainly one way to go. If we go that way, it would probably be a good idea to make `:rw` identical to `:r, :w` and make the *opposite* of `:create` into an adverb (`:exists`?).\r\n\r\nI'll have to think about it some more, but the basic building blocks would be\r\n\r\n    :r :w :exists :append :truncate :exclusive\r\n\r\nwith the possibility of shortcuts, eg\r\n\r\n    :rw --> :r :w\r\n    :a   --> :w :append\r\n"}}