On Thu, Apr 22, 2004 at 10:34:25AM -0400, Aaron Sherman wrote: : But, what happens if I: : : { : use bytes; : my string $line = $filehandlelikething.getline; : }
That might depend on how $filehandlelikething was opened. A filehandle is going to return a string of the type requested when you opened it. As you've written it there, it would presumably try to do a downconversion depending on the definition of "string", which is not a built-in type. Alternately, it could be argued that automatic downconversion is a bad default, and the default should just be to die on a type mismatch unless a coercion is explicitly defined between the two types. (C<Str> is the built-in string object type, which probably forces no conversion, presuming conversion is lazy. The builtin C<str> type I'm not so sure about. It might force an octets view. Or maybe we only have bstr, cstr, gstr and lstr, to force bytes, codepoints, graphemes, and letters, and str is an alias to the correct type under the current lexical Unicode support level.) : Does my saying "string" enforce anything, or do I have to: : : { : use bytes; : my string $line is bytes = $filehandlelikething.getline; : } If you want to force a conversion, it's more likely to look like my $line = $filehandlelikething.getline as bstr; or some such. That would be a downconversion, and potentially lossy or "exceptional". If what you want is to treat the internal representation of the string as a sequence of bytes, you'd have to say something else, probably a method on Str to get it to divulge its innards. In which case you're almost certainly on your own as to the interpretation of those bytes. Assume that Perl 6 will change its internal implementation of strings regularly just to keep you on your toes. :-) Larry