dmt: Python-like indentation in D programming language

Witold Baryluk witold.baryluk+d at gmail.com
Tue Nov 16 21:58:24 UTC 2021


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.



More information about the Digitalmars-d-announce mailing list