Adding D support to Clang format
Johan
j at j.nl
Sat Apr 29 10:46:45 UTC 2023
On Saturday, 29 April 2023 at 10:08:41 UTC, Johan wrote:
> On Friday, 28 April 2023 at 23:30:37 UTC, Zachary Yedidia wrote:
>> Clang format is a high quality auto-formatter developed by the
>> LLVM project, mainly for use with C and C++, but it also
>> supports Java, C#, JavaScript, JSON, Objective-C, Proto,
>> TableGen, TextProto, and Verilog. I think it would be great to
>> add support for D, and hopefully shouldn't be too difficult
>> since it is a C-like language.
>
> clang-format is indeed a godsent formatter.
> I recently also read that it can do languages quite different
> from C, and hoped for D support in the future.
> It will be very nice for people (like me) who work on mixed
> C++/D codebases.
>
>> I have started an implementation for D here:
>> https://github.com/zyedidia/llvm-project/tree/clang-format-d,
>> with some information about the implementation here (how to
>> download/build/test):
>> https://github.com/zyedidia/llvm-project/blob/clang-format-d/clang-format-d.md.
>
> Great you are picking this up and leading the effort!
> Hope to be able to help out.
I'm enthusiastic, but after some more thinking I think it's wise
to talk with the sdfmt team and discuss which way to go: better
to have everyone work on one project, rather than two. I'm very
interested in working on a good formatter, but not two ;-)
Perhaps the upsides of clang-format (what is already there) are
not so large.
A big downside of clang-format is that you are tied to LLVM's
project (release schedule, way of working, community, ...). In
order to format D code, you'd have to install clang-format (and
the whole LLVM dependency?). And you are programming in C++,
which is a pity for a project that is purely for D.
Because sdfmt has its own 'parser' (excellent!), it is quite a
small program that can easily be built using `dub`. That makes
the barrier to entry for developers very small (no need to build
or test `sdc` itself).
-Johan
More information about the Digitalmars-d
mailing list