Author: wayland Date: 2009-02-18 12:16:00 +0100 (Wed, 18 Feb 2009) New Revision: 25382
Modified: docs/Perl6/Spec/S16-io.pod Log: Fixed some things people were complaining about. Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-02-18 11:11:32 UTC (rev 25381) +++ docs/Perl6/Spec/S16-io.pod 2009-02-18 11:16:00 UTC (rev 25382) @@ -54,6 +54,16 @@ This role provides unbuffered read access to the data stream. +role IO::Readable { + has $.isReadable; + + method Int read($buf is rw, Int $length) +} + +When the $.isReadable is set, it tries to change the readability of the filehandle. This +is not always possible, but can be done in a number of cases. IO::Socket can remove +readability by calling shutdown(), for example. + =over =item method Int read($buf is rw, Int $length) @@ -68,17 +78,22 @@ you're going to need to encode it later, or use "getc" or other IO::Readable::Encoded methods. -=item method Bool is_readable() - -Indicates whether socket is actually opened for reading. Closed sockets -return false. - =back =head2 IO::Writeable This role provides unbuffered write access to the data stream. +role IO::Writeable { + has $.isWriteable; + + method Int write($buf, Int $length) +} + +When the $.isWriteable is set, it tries to change the writeability of the filehandle. +This is not always possible, but can be done in a number of cases. IO::Socket can remove +writeability by calling shutdown(), for example. + =over =item method Int write($buf, Int $length) @@ -92,11 +107,6 @@ encoded data, you should decode it first, or use "print" or other IO::Writeable::Encoded methods. -=item method Bool is_writeable() - -Indicates whether socket is actually opened for writing. Closed sockets -return false. - =back =head2 IO::Seekable @@ -356,6 +366,19 @@ method IO::Socket accept() +=head2 IO::FileDescriptor + +This role indicates that this object actually represents an open file +descriptor in the os level. + +=over + +=item method int fileno() + +File descriptors are always native integers, conforming to C89. + +=back + =head2 Tree Roles and Classes To support the filesystem, it is also useful to define some generic tree roles, which @@ -535,7 +558,7 @@ multi method infix:{'<=>'}(DateTime $self, DateTime $other); multi method infix:{'<=>'}(DateTime $self, Duration $other); - method new(Str $String); + method new(:$String); method truncate(Str $to); method last(Str $type, Str $of); method toString($format?); @@ -548,7 +571,7 @@ =item new - method new(Str $String) # parser defaults to 'strptime' or something similar + method new(Str :$String) # parser defaults to 'strptime' or something similar | (Str $parser, Str $String) # $parser = 'strptime' | (Str $parser, Int $Epoch) # $parser = 'epoch' | (Str $parser, Str $Timezone?) # $parser = 'today' [unless strptime does this] @@ -596,8 +619,8 @@ =item new - method new(Str $filename, $options?); - method new(Int $fd); + method new(Str :$filename, $options?); + method new(Int :$fd); # Read $fobj = new IO::File($filename); @@ -815,12 +838,18 @@ This is called automatically on object creation. -multi method new(@pathelements); # new IO::FSNode('home', 'wayland') -multi method new(String $type, String $path) # new IO::FSNode('Unix', '/home/wayland'); -multi method new(String $path) # new IO::FSNode('/home/wayland'); +multi method new(Array of Str :@pathelements); +multi method new(String :$type, String :$path); +multi method new(String :$path); This last throws an error if "use portable" pragma is used. +Examples: + + $fsnode = new IO::FSNode(pathelements => ['home', 'wayland']); + $fsnode = new IO::FSNode(type => 'Unix', path => '/home/wayland'); + $fsnode = new IO::FSNode(path => '/home/wayland'); + =back =head2 IO::FSNodeACL @@ -916,11 +945,11 @@ =item new - method Bool new( - $RemoteHost, $RemotePort, - $LocalHost?, $LocalPort?, - $Blocking?, - $NoOpen? + method IO::Socket::TCP new( + :$RemoteHost, :$RemotePort, + :$LocalHost, :$LocalPort, + :$Blocking, + :$NoOpen ); The creation of the object will also open the connection, unless NoOpen is specified. @@ -1010,19 +1039,6 @@ =head2 Unix -=head2 IO::FileDescriptor - -This role indicates that this object actually represents an open file -descriptor in the os level. - -=over - -=item method int fileno() - -File descriptors are always native integers, conforming to C89. - -=back - =head2 IO::FSNode::Unix =item chown @@ -1170,7 +1186,7 @@ =item IO.shutdown() -Gone, see IO::Socket.close() +Gone, see IO::Socket.close(), $IO::Readable.isReadable, and $IO::Writeable.isWriteable =item socketpair