dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Nov 5 10:30:27 UTC 2021


On Friday, 5 November 2021 at 10:13:13 UTC, Guillaume Piolat 
wrote:
> Well you only know that it is meant to be utf8 in the context 
> of the auto-decoding foreach (which must still exist). string 
> in actual programs may contains binary files, strings in other 
> codepages encodings.

D needs to rethink strings. Newbies going for "scripty" 
programming really need an encapsulated strongly typed string 
type, accessed only through functions that do-the-right-thing.

I think @safe/@system distinction would be more useful if @safe 
was for those that wanted a more "scripty" programming style and 
@system was for those that wanted a more "low level" programming 
style.

On a related note, I also think it would be useful to have 
something stronger than @safe, like a  @non-trojan marker for 
libraries, which basically says that it is impossible for that 
library to do evil and have that statically checked by the 
compiler. Then you could import libraries without caring about 
bad code. One issue I have with packages in smaller languages is 
that you don't have enough eyeballs on them, too easy for "evil" 
code to slip through (intentionally or not).




More information about the Digitalmars-d mailing list