# New Ticket Created by  Christian Bartolomaeus 
# Please include the string:  [perl #131145]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131145 >


Some of the newly added tests for IO::Handle.open with different 
modes fail on the JVM backend. The basic modes (:r, :w, :x, :a) and
combinations of those do work as expected, but there are problems 
with :append and :create and :ra.

Just now I found https://github.com/rakudo/rakudo/commit/36f773eb01
where those modes where added (I only looked at docs.perl6.org
before). From the commit message I learned:

  :append was not meant as a synonym for :a

  :ra was not meant to stand for "read + append"

  :r, :a was not meant to stand for "read + append"

The first one surprised me the most. But indeed :a and :append work
differently:

  $ rm -f foo 2>/dev/null; ./perl6-m -e '"foo".IO.open(:a)'; ls -s foo
  0 foo

  $ rm -f foo 2>/dev/null; ./perl6-m -e '"foo".IO.open(:append)'; ls -s foo
  Failed to open file /path/to/rakudo.moar/foo: no such file or directory
    in block <unit> at -e line 1

  Actually thrown at:
    in block <unit> at -e line 1

  ls: foo: No such file or directory

What poses a problem for rakudo-j is, that :append and :create
(without :w) are assumed to mean "read" with Java and those
combinations (append + read) and (create + read) do not work well. [2]

IMHO a clarification is needed. If we want the additional modes as
described in rakudo commit 36f773eb01 (and as implemented, bugs
notwithstanding) then we should

* define that :append and :create always imply "write"

* change the implementation for the JVM backend so that the newly
  added tests pass

* expand the documentation of "open"

See also the discussion on #perl6-dev:
https://irclog.perlgeek.de/perl6-dev/2017-04-13#i_14424307

[1] 
https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#open-java.nio.file.Path-java.util.Set-java.nio.file.attribute.FileAttribute...-

Reply via email to