This should go to the list also: "Gregor N. Purdy" <[EMAIL PROTECTED]> writes:
> 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'm not arguing for removing PIO_puts et al., I want to remove ParrotIOLayerAPI.PutS. Both calls Write and PutS take a pointer to raw data; the first one with a len, the second one with terminating '\0'-byte. There is no version which takes a Parrot-String with encodings. A unified version of ParrotIOLayerAPI.Write might have the signature Write(struct ParrotInterp *, ParrotIOLayer *, ParrotIO *, Buffer *); > 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. This is another problem. Should this recoding be done in the IO-subsystem? This data-recoding might be another layer on top of the others. But then the Parrot-String must be passed down to the layers. This demands even more a unified version, because the current version does not pass this information down. bye boe -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47