pugs-comm...@feather.perl6.nl writes:
> +=item method Int read($buf is rw, int $length)

I'm not sure that using a native int is the right thing here.  If
whatever the implementation uses as int is narrower than size_t, that
forces the programmer to use an Int and do the necessary loop.

On the other hand, accepting Int allows bignums.  If a bignum $length
is too big to be represented by a native int, but still small enough
to use as a byte count for an I/O operation, then .read can do the
loop internally, freeing the programmer from worrying about such
things.  (And if $length is too big for the memory space, or otherwise
inappropriate for .read, we can throw an exception.)

> +Tries to read $lenght bytes and store in $buf. The contents of $buf

Typo; should be "$length", obviously.

> +=head2 IO::Writeable

FWIW, I prefer the traditional spelling, "writable".  Google suggests
that "writeable" is more common on the web, though; 4.8 versus 3.7
Mghits.

> +=head2 IO::POSIX
> +
> +Indicates that this object can perform standard posix IO operations.

I don't like that wording, but getting it right seems tricky.  The
problem is that I don't think you mean for IO::POSIX to contain
methods corresponding to POSIX-ish read(2), write(2), given that
methods of those names exist in other roles.  But those are precisely
what I'd think of as most obviously falling into the category of
"standard POSIX I/O operations".

> +=item method Bool flock(:$r,:$w)

I realise this part of the specification still seems to be at the stub
stage, but I'll note that:

* We'll also need a way of getting at the LOCK_NB behaviour

* The normal terms for flock() are "shared" and "exclusive" locks, not
  "read" and "write" locks

* It seems a little odd to put an flock method in an IO::POSIX role,
  given that POSIX specifies fcntl(F_SETLK) in place of traditional
  BSD-ish flock().  I'd be in favour of having .fcntl in IO::POSIX, but
  with an additional role providing .flock (IO::Flock, presumably).

-- 
Aaron Crane ** http://aaroncrane.co.uk/

Reply via email to