Feedback on Átila's Vision for D

Radu void at null.pt
Fri Oct 25 05:47:27 UTC 2019


On Friday, 25 October 2019 at 05:23:33 UTC, Radu wrote:
> On Thursday, 24 October 2019 at 21:29:08 UTC, Walter Bright 
> wrote:
>> On 10/24/2019 5:35 AM, Radu wrote:
>>> [...]
>>
>> 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.
>
>>
>>> [...]
>>
>> 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
> ```

Taken from the samples on front page
```
struct Point
{
     private double[2] p;
     // Forward all undefined symbols to p
     alias p this;
     double dot(Point rhs)
     {
         return p[0] * rhs.p[0] + p[1] * rhs.p[1];
     }
}

extern(C) void main()
{
     Point p1, p2; p1 = [2, 1], p2 = [1, 1];
     assert(p1[$ - 1] == 1);
}
error: undefined reference to '_memsetDouble'
collect2: error: ld returned 1 exit status
```
Same works in LDC, imagine you want to support both compilers...


More information about the Digitalmars-d mailing list