I'm looking for, but not finding, information regarding the character type and encoding on parrot io objects.
As an example of why... I found this in io.ops : op write(in PMC) { PMC *p = $1; STRING *s = (VTABLE_get_string(interpreter, p)); if (s) { PIO_write(interpreter, PIO_STDOUT(interpreter), s->strstart, s->bufused); } goto NEXT(); } Surely, blinding writing the bytes that are in a string, without checking that the string's encoding and type match that of the stream, is wrong. I would expect something like: op write(in PMC) { PMC *p = $1; STRING *s = VTABLE_get_string(interpreter, p); if( s ) { PMC *o = PIO_STDOUT(interpreter); string_transcode(interpreter, s, PIO_encoding(interpreter, o), PIO_chartype(interpreter, o), &s); PIO_write(interpreter, o, s->strstart, s->bufused); } goto NEXT(); } Except that I can't seem to find any PIO_encoding and PIO_chartype functions. ############# Actually... I think that the op print(in PMC) and write(in PMC) are designed wrong. Instead of asking for a string, and printing that string, they should call a print_self and/or write_self vtable method on the PMC, passing in the PIO object. In turn, the default implementations of those methods should print or write the results of DYNSELF.get_string() to that PIO object. This way, a PMC whose string representation is very large doesn't need to serialize itself to a string before it can be printed -- it can print itself directly to the PIO object, thus avoiding allocating memory for that big string, and probably lots of copying. To avoid loss of synchronization between the get_string form of a pmc and the print_self/write_self form of a pmc, one should be able to define a string's get_string as creating a new stringstream PIO object, printing itself to that stream, and returning the corresponding string. However, there doesn't (yet) seem to be a stringstream layer. When do we expect to have one? ############# PIO_putps converts to a cstring, then calls PIO_puts. Since PIO_puts doesn't take a length, obviously it must be determining the length of the string based on the presence of a nul character in it. Thus, we cannot use PIO_puts to print binary data. This means that PIO_write must be used. Since there's no op write(in STR), the only way to do it from parrot is to create a PerlString, store our Sreg into it, then call write. Blech. ############# Shouldn't everything in io_unix.c (except for pio_unix_layer) be static? This isn't "just" about namespace pollution -- it slows down linking and dynamic loading. I think. Hmm, the same applies to the other io_foo.c files. ############# Why does PIO_unix_seek clear errno before calling lseek? ############# Why does PIO_unix_tell have a temp variable "pos"? -- $a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca );{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED] ]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}