[MLton] Windows ports and paths

Wesley W. Terpstra wesley@terpstra.ca
Mon, 2 May 2005 23:30:13 +0200


On Mon, May 02, 2005 at 11:01:48PM +0200, Andreas Rossberg wrote:
> >        else if 0 = size dir then file
> 
> Actually, this test will be wrong on Windows, where dir can be a path with
> no arcs but a volume. :(
> 
> The obvious correct implementation is
> 
>         fun joinDirFile {dir, file} =
>             let
>                 val {isAbs, vol, arcs} = fromString dir
>             in
>                 toString {isAbs=isAbs, vol=vol, arcs=arcs@[file]}
>             end

I second this version of the method! :-)

> Slightly suboptimal efficiency-wise, though...

I think clarity is best here; disk ops will drown this out anyways.

... speaking of which:
            val arcs =
               case (a1, a2) of
                  ([], []) => []
                | _ =>
                     (case List.rev a1 of "" :: r => List.rev r | _ => a1) @ a2
is a rather long way of writing
            val arcs =
               (case List.rev a1 of "" :: r => List.rev r | _ => a1) @ a2
no?

-- 
Wesley W. Terpstra <wesley@terpstra.ca>