I want off Mr. Golang's Wild Ride

Sönke Ludwig sludwig+d at outerproduct.org
Sat Feb 29 07:41:41 UTC 2020


Am 29.02.2020 um 06:50 schrieb Walter Bright:
> On 2/28/2020 8:54 PM, H. S. Teoh wrote:
>> The most glaring point to me is Phobos' ubiquitous use of `string`
>> everywhere for filenames. The fact that strings are assumed to be valid
>> UTF-8 will almost certainly land us in the same complaints as the author
>> had about Go's handling of pathnames.
>>
>> Changing that would be a major code breaker, though. So I'm not sure if
>> we should even attempt to!
> 
> This is an interesting problem. I don't know about Rust, but in D a 
> string's contents are not guaranteed to contain valid UTF-8. For the 
> string algorithms I've worked on, I always made them to be tolerant of 
> bad UTF, for the simple reason that bad UTF is everywhere and having the 
> program aggressively halt on it is overkill. The only time validity is 
> checked is when decoding is attempted, or *cough* autodecode *cough* is 
> running, which I'd circumvent.
> 
> So I expect we are in good shape there.
> 
> Things we must specifically review, however, are:
> 
> 1. the way stat is dealt with
> 
> 2. the way file extensions are determined
> 
> 3. the \ vs /
> 
> and more generally, follow the principles outlined in the article.

This is why there are UnixPath, WindowsPath and InetPath types defined 
in vibe.d (with NativePath being an alias to WindowsPath or PosixPath). 
Typing everything as `string` is a recipe for disaster, unless the 
library semantics happen to exactly match the handled path type.

https://vibed.org/api/vibe.core.path/

I'm still not happy with the way absolute paths are handled in terms of 
path segments in the current design, I just haven't found a way to 
improve it without breaking existing code in strange ways.

(OT: Can you please quickly check your inbox/spam folder? I've send a 
mail a few days ago, as well as a copy today, regarding code.dlang.org)


More information about the Digitalmars-d mailing list