C's Biggest Mistake on Hacker News
Arun Chandrasekaran
aruncxy at gmail.com
Fri Jul 27 00:53:35 UTC 2018
On Tuesday, 24 July 2018 at 11:53:35 UTC, Ecstatic Coder wrote:
> On Tuesday, 24 July 2018 at 10:40:33 UTC, Dukc wrote:
>> On Monday, 23 July 2018 at 15:06:16 UTC, Ecstatic Coder wrote:
>>> And something that REALLY must be integrated into BetterC's
>>> low-level standard library in some way IMHO...
>>
>> They already work, except for the concatenation operator
>> because it obviously requires the GC. And converiting a
>> pointer from C code to D is easy, because you can slice
>> pointers just like arrays -it's just that it won't be bounds
>> checked.
>
> Nice.
>
> But if you want D to be REALLY appealing to a majority of C++
> developers, you'd better provide them with the FULL D
> experience.
>
> And unfortunately, using builtin arrays/strings/slices/maps in
> the usual way is probably a big part for it.
>
> Don't forget that concatenating strings in C++ is perfectly
> ALLOWED in C++, WITHOUT using a GC...
>
> #include <iostream>
>
> using namespace std;
>
> int main()
> {
> string str, str1, str2;
> str1 = "Hello";
> str2 = "World";
> str = str1 + " " + str2;
> cout << str << endl;
>
> return 0;
> }
>
Recently in my code base where similar concatenation worked fine
in debug mode but crashed in release mode: Win64, VS2017. Worked
fine on Linux, GCC 7.3. Had to use std::ostringstream to resolve
it, or use use .append().
These kind of UB is what makes a language esoteric. C wins the
lot for UBs nevertheless!
More information about the Digitalmars-d
mailing list