Alternative to C++ macro in D

Vinod K Chandran kcvinu82 at gmail.com
Sun Nov 3 17:02:30 UTC 2019


On Sunday, 3 November 2019 at 16:55:36 UTC, Vinod K Chandran 
wrote:
> Hi all,
> I can do this in C++.
> #include <iostream>
> using namespace std ;
>
> #define end };
> #define log(x)  cout << x << endl
> #define wait std::cin.get()
>
>
> int main() {
>     log("Trying to avoid the visual clutter aused by closing 
> curly braces") ;
>     string myStr = "Now, code looks more elegant" ;
>     log(myStr) ;
>     wait ;
> end
> How can i do this in D ? Especially the " #define end }; ". 
> I've tried " alias end = } " but didn't worked.
> Edit : How can add syntax highlighting and coloring in code 
> posted on this comment ?

How can i edit my post ? There is no button or link to edit my 
post.


More information about the Digitalmars-d-learn mailing list