On Thursday, 10 June 2021 at 15:57:44 UTC, Imperatorn wrote:
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why can't we use [pegged](https://github.com/PhilippeSigaud/Pegged) to transpile C++ code to D? Then we won't need a nogc compatible std library and so many other things could get easier, like getting legacy code to use Dlang. It might not be worth it for C+17 and beyond, but older codebases could benefit significantly, right?

I'm guessing it's hard because of the grammar

Well, still a grammar, though it was my little WTF moment.

for example this C++ grammar(often used in STL) where min is simple minimum function

```cpp
float min(float l, float r)
{
   return (l < r) ? l : r;
}
```

```cpp
float foo(float a, float b) {
   return (min)(a,b);
}
```

and this direct translation to D doesn't works
```d
float foo(float a, float b) {
return (min)(a,b); // Error: C style cast illegal, use `cast(min)(a , b)`
}
```

but this does
```d
float foo(float a, float b) {
   return (&min)(a,b); // ok
}
```

Reply via email to