Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modes for IO::Handle.open need clarification #6189

Closed
p6rt opened this issue Apr 13, 2017 · 7 comments
Closed

Modes for IO::Handle.open need clarification #6189

p6rt opened this issue Apr 13, 2017 · 7 comments
Labels
JVM Related to Rakudo-JVM

Comments

@p6rt
Copy link

p6rt commented Apr 13, 2017

Migrated from rt.perl.org#131145 (status was 'resolved')

Searchable as RT131145$

@p6rt
Copy link
Author

p6rt commented Apr 13, 2017

From @usev6

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 rakudo/rakudo@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...-

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

From @usev6

On Thu, 13 Apr 2017 12​:21​:57 -0700, bartolin@​gmx.de wrote​:

[...]
* expand the documentation of "open"

That was done by Zoffix++ with Raku/doc@ca2a3a0bfb

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

From @usev6

On Thu, 13 Apr 2017 12​:21​:57 -0700, bartolin@​gmx.de wrote​:

[...]
* define that :append and :create always imply "write"

That was also done by Zoffix++ -- mainly with Raku/roast@091931a717

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

From @usev6

On Sat, 10 Mar 2018 11​:40​:24 -0800, bartolin@​gmx.de wrote​:

On Thu, 13 Apr 2017 12​:21​:57 -0700, bartolin@​gmx.de wrote​:

[...]
* define that :append and :create always imply "write"

That was also done by Zoffix++ -- mainly with
Raku/roast@091931a717

Sorry, that comment wasn't clear. What I meant was, that the different open modes were specced in S32-io/open.t with said commit.

@p6rt
Copy link
Author

p6rt commented Mar 21, 2018

From @usev6

On Thu, 13 Apr 2017 12​:21​:57 -0700, bartolin@​gmx.de wrote​:

[...] then we should

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

The tests for open modes are passing now on the JVM backend. I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Mar 21, 2018

@usev6 - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 21, 2018
@p6rt p6rt added the JVM Related to Rakudo-JVM label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JVM Related to Rakudo-JVM
Projects
None yet
Development

No branches or pull requests

1 participant