Juergen --

Juergen Boemmels wrote:

Write
PutS
  Why are there two diffrent calls to write data to an io, with only a
  slightly different prototype. This is code-duplication in every
  layer. I can't think of any use case where PutS won't be implemented
  as Write(..., data, strlen(data)). These two calls could be unified.
  As a side note: The primary memory structure is the buffer, maybe
  the unified call should take a buffer argument.
-> unify these two

We need to be careful here about the difference between C strings and Parrot strings. For your basic C string strlen(data) is the way to decide how many bytes to write. For Parrot strings, we can have internal zero bytes (or the lack of a trailing zero byte) that will throw off strlen and therefore screw things up.

I have a patch on my workstation (currently in transit from Cincinnati
to Seattle, so not accessible -- but, I've discussed a bit with Dan on
IRC) that tries to deal with this issue by having a "*c" (for C-style)
and a "*l" (for length-style) variant of a couple functions (including
changes to vtables stuff, IIRC).

But, that leaves out another important piece: If we have a Parrot string
in some encoding, and we are going to Write/Put it to STDOUT, which is
headed for someone's terminal, we might need to do more than just blast
the buffer if we expect the user to do anything other than curse us and
our mothers.


Regards,


-- Gregor



Reply via email to