dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead
Imperatorn
johan_forsberg_86 at hotmail.com
Fri Nov 5 08:04:17 UTC 2021
On Friday, 5 November 2021 at 06:15:44 UTC, Walter Bright wrote:
> On 11/4/2021 9:11 PM, max haughton wrote:
>> On Friday, 5 November 2021 at 04:02:44 UTC, Walter Bright
>> wrote:
>>> On 11/4/2021 7:41 PM, Mathias LANG wrote:
>>>> If you want to fix it, just deprecate the special case and
>>>> tell people to use `foreach (dchar d;
>>>> someString.byUTF!(dchar, No.useReplacementDchar))` and voilà.
>>>> And if they don't want it to throw, it's shorter:
>>>> `foreach (dchar d; someString.byUTF!dchar)` (or `byDChar`).
>>>
>>> People will always gravitate towards the smaller, simpler
>>> syntax. Like [] instead of std::vector<>.
>>
>> I have never observed this mistake in any C++ cod,
>
> You've never observed people write:
>
> int array[3];
>
> in C++ code?
>
>> unless you mean as a point of language design.
>
> D (still) has a rather verbose way of doing lambdas. People
> constantly complained that D didn't have lambdas. Until the =>
> syntax was added, and suddenly lambdas in D became noticed and
> useful.
>
>
>> This decision should be guided by how current D programmers
>> act rather than a hyperreal ideal of someone encountering the
>> language.
>
> The only reason D's associative arrays continue to exist is
> because they are so darned syntactically convenient.
>
> I've seen over and over and over that syntactic convenience
> matters a lot.
*The value of convenience should not be underestimated*
It's what enables productivity, which in my opinion should be
*the* main metric of success. Everything else is just "fluff".
In how many seconds can you transform idea A into program B.
That is how you measure success imo.
It doesn't matter if you have a cool or super interesting way of
achieving something, if person X is still trying to figure out
how to do some cool thing while person Y is already done and
focusing on the next thing, person X has lost.
Because, person Y always optimize and refractor later (before the
deadline), but person X can't because the deadline is already
over.
*The value of convenience should not be underestimated*
More information about the Digitalmars-d
mailing list