Feedback on Átila's Vision for D

Radu void at null.pt
Fri Oct 25 05:23:33 UTC 2019


On Thursday, 24 October 2019 at 21:29:08 UTC, Walter Bright wrote:
> On 10/24/2019 5:35 AM, Radu wrote:
>> And this comes from a semi failed experiment of mine trying to 
>> code a C library in D using -betterC. My conclusions:
>> 
>> - You miss the nice dynamic arrays and hash map structures, 
>> and others. You end-up rolling your own or wrapping C 
>> libraries, which requires lots of effort.
>> - There is no way to generate C/C++ header files from your 
>> extern(C/C++) declaration, I know this is being worked on. So 
>> had to roll my own.
>> - I had to roll out my own RefCount, Nullable and friends.
>> - At that time copy ctor was not available, so me wanting to 
>> properly use immutable for non POD types was a pain.
>> - CTFE is severely limited.
>> Most of these are tracked as bugs already, in case 
>> *thatsomeone* asks :)
>
> Since all but the second item are not C features, I don't see 
> how these caused your DasBetterC project to fail.
>

What do you mean? They are D issues, the only C "feature" you 
really use is the extern(C)
declaration on the API level.

>
>> but still has warts like no betterC CTFE.
>
> Specifics, please.
>
> BTW, many of Phobos' modules are template only, meaning they 
> should work with betterC.

```
string foo()(string a, string b)
{
     return a ~ b;
}

extern(C) void main()
{
    enum x = foo("a", "b");
}
Error: array concatenation of expression a ~ b requires the GC 
which is not available with -betterC
```
Hey ho
https://issues.dlang.org/show_bug.cgi?id=20086
https://issues.dlang.org/show_bug.cgi?id=20101
https://github.com/dlang/dmd/pull/8253

Some algorithms are working indeed but it is a stupid trial and 
error exercise each time you want to use some template code from 
std. And you risk that the next compiler release could break 
them, because they are not really tested against -betterC.

```
import std.bitmanip : bitsSet;
import std.algorithm.comparison : equal;

extern(C) void main()
{
   assert(bitsSet(1).equal([0]));
}
Error: TypeInfo cannot be used with -betterC
```



More information about the Digitalmars-d mailing list