On Tuesday, 16 November 2021 at 21:58:24 UTC, Witold Baryluk wrote:
Hi,

`dmt` is an old project of mine from around year 2006. I ported it recently from D1 to D2, and added some extra features and support for extra keywords, and fixed few bugs here and there.

`dmt` is a converter (offline or auto-invoking compiler after conversion) from Python-like indention style to curly braces for D programming language.

https://github.com/baryluk/dmt

It is fun and easy to use, and maybe it would be of interested to you.

`example.dt`:

```d
def int f(int b):
    int y = 0
    foreach (i; 0..5):
      y += i * (i+b)
    return y

struct A:
    private:
    int a
    public:
    int b_ = 5
    def auto b() @property:
        return b_

def void main():
    import std
    writefln!"%s %s"(f(5), A())
```

```shell
$ DMD=ldc2 dmt -run example.dt
ldc2 -run example.d
80 A(0, 5)
$
```

All D programming language features are supported (including exception handling, if/else, switch/case/break, inline asm, attribute sections, goto). Converted code is human readable.

You can check more examples in the README.md and in `tests/` directory.

`dmt` is not yet self hosting, but that is probably the next step. :)

Enjoy.

Isn't def redundant in this since D already declares types then you can assume if it's not enum, template, mixin template, class, struct or union then it must be a function if it also end with (...):

Like:

    ```d
    int foo():
        return 10
    ```

You'd never be in doubt that foo was a function or that:

    ```d
    template Foo(T):
        alias Foo = T
    ```

Foo in this case was a template.

Or like make def optional at least, because I see how it can help porting Python code, but it seems unnecessary if you're writing from scratch.

Great project tho!

Reply via email to