DEV Community

Jesse Phillips
Jesse Phillips

Posted on

6

Comments in D

In my continued attempts to write in Python, I desired to comment out some code. I tried an assortment of styles including ; but I still had to search because I had forgotten #

D follows the C++ comments.

// single line
/*
  Multi-line
*/
Enter fullscreen mode Exit fullscreen mode

It goes a step further with nested comments.

/*
/*
  Multi-line
*/
This is not a comment 
*/

/+
/+
  Multi-line
+/
We are still a comment
+/
Enter fullscreen mode Exit fullscreen mode

If you place an additional character in the comment start, then these comments are eligible for documentation generation.

/// Document comment
/** doc comment */
/++ comment for docs +/
Enter fullscreen mode Exit fullscreen mode

Well D does not stop there and provides a different way to prevent code from compiling.

version (none) {
    auto var = 85;
}
Enter fullscreen mode Exit fullscreen mode

It is still run through the parser, but otherwise is not required to compile successfully.

Top comments (0)

nextjs tutorial video

πŸ“Ί Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay