Re:Custom string delimiters in Swift 5
by arcticbull on Thursday December 27, 2018 @10:59PM
(#18774792)
Why would URL be needed to handle file system only paths? They’re different and OS Specific. Rusts Path vs String vs third-party URL strikes the right balance IMO. It’s a third thing.
[ Parent
| on HN ]
Re:Custom string delimiters in Swift 5
by saagarjha on Friday December 28, 2018 @04:12AM
(#18775713)
Foundation’s URL handles file system paths, among other things. Thus, it is the right choice to do path-based operations.
Re:Custom string delimiters in Swift 5
by arcticbull on Saturday December 29, 2018 @12:48PM
(#18784745)
Sorta, it's the right choice on iOS and macOS but conceptually filesystem paths are different than URIs even though the same information can be encoded into both. It's weird to have URIs pointing at google (technically valid by means of being the same type) being passed to file-management APIs - only to have them unsurprisingly fail. It subverts the type system by allowing invalid blobs to avoid being caught by the type system. Paths as URIs in contexts where only FS paths are valid is akin to any other stringly-typed API. A third type is more logical: URL, String and FsPath.