[racket] Reader constructor for #<path:....>
2010/7/26 Laurent <laurent.orseau at gmail.com>:
>
>
> On Mon, Jul 26, 2010 at 14:43, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>
>> At Mon, 26 Jul 2010 14:29:57 +0200, Laurent wrote:
>> > The reader cannot read #<path:....> forms (is this the right term?).
>> > When the interaction window is in constructor mode, for (build-path "a"
>> > "b"), it writes #<path:a/b>, but this cannot be read back.
>> >
>> > First question: would it be possible to make the reader read paths?
>>
>> The reason that paths are not `read'able is that's there is not a
>> single right choice for how to marshal paths:
>>
>> * Sometimes you want the string form of a path, which may be encoded
>> in different ways on different platforms (e.g., using different
>> locales) to keep the string form the same.
>>
>> * Sometimes you want the bytes form of a path, because the path isn't
>> going to be used on multiple systems, and converting to a string
>> form may lose information (e.g., because it's not a UTF-8 encoding).
>>
>> Since there was no right answer, we decided not to pick either of them.
>> The lack of a `read'able form is a weak hint to programmers that they
>> need to look closely at the question.
>
> Thanks, I understand.
> Maybe we could distinguish between `read'able and un`read'able paths?
But there are no (guaranteed to be) readable paths because the
underlying filesystem may use a bizarro encoding. (I think you're
unlikely to run into problems with (7-bit) ascii paths, but I don't
think that it is guaranteed.)
Robby