<br><br><div class="gmail_quote">On Mon, Jul 26, 2010 at 14:43, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">At Mon, 26 Jul 2010 14:29:57 +0200, Laurent wrote:<br>
> The reader cannot read #<path:....> forms (is this the right term?).<br>
> When the interaction window is in constructor mode, for (build-path "a"<br>
> "b"), it writes #<path:a/b>, but this cannot be read back.<br>
><br>
> First question: would it be possible to make the reader read paths?<br>
<br>
</div>The reason that paths are not `read'able is that's there is not a<br>
single right choice for how to marshal paths:<br>
<br>
* Sometimes you want the string form of a path, which may be encoded<br>
in different ways on different platforms (e.g., using different<br>
locales) to keep the string form the same.<br>
<br>
* Sometimes you want the bytes form of a path, because the path isn't<br>
going to be used on multiple systems, and converting to a string<br>
form may lose information (e.g., because it's not a UTF-8 encoding).<br>
<br>
Since there was no right answer, we decided not to pick either of them.<br>
The lack of a `read'able form is a weak hint to programmers that they<br>
need to look closely at the question.<br></blockquote><div><br>Thanks, I understand.<br>Maybe we could distinguish between `read'able and un`read'able paths?<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> Second question: I need this for my own purposes, so I wrote a<br>
> path-constructor:<br>
> (define/provide (write-path p)<br>
> (cons 'build-path<br>
> (map (ë(p-elt)(if (symbol? p-elt)<br>
> (list 'quote p-elt)<br>
> (path->string p-elt)))<br>
> (explode-path p))))<br>
><br>
> > (write-path (build-path 'same 'up "a" "b"))<br>
> '(build-path 'same 'up "a" "b")<br>
><br>
> Does someone know if this is good enough, or am I omitting something<br>
> (platform specific maybe)?<br>
<br>
</div>As a minimum, use `path-element->string' instead of `path->string'.<br>
<br>
Otherwise, beware that (as noted above) not all paths have string<br>
encodings; depending on your application, that may not be an issue. Or<br>
it may be that you want to marshal via byte strings using `bytes->path'<br>
as a constructor.<br></blockquote><div><br>Thanks a lot Matthew! <br></div></div><br>