Topic: Proposal for enhanced preprocessing


Author: stuart.heinrich@gmail.com
Date: Mon, 24 Jul 2006 16:46:29 CST
Raw View
I would enjoy seeing an extension to c++ that allowed more complicated
embedded preprocessor directives specified [i]in C++ syntax[/i], much
like PHP does for webpages.

I would argue that this kind of flexibility would be able to greatly
increase coding efficiency in some scenarios, and provides much more
power than the standard macro.

If you don't understand what I'm talking about then here's an example.
I have made up the "/#" and "#/" directives to mean start/end
preprocessor step.

PROPOSED EXAMPLE:

#include <stdio.h>

int main(int argc, char **argv)
{
 /#
  for(int i=0; i<3; i++){
   printf(temp, "printf(\"%i\");", i);
  }
 #/
}

PROPOSED OUTPUT OF PREPROCESSOR:

#include <stdio.h>

int main(int argc, char **argv)
{
 printf("0");printf("1");printf("2");
}


I would also like to echo the suggestions of others who have mentioned
the desire for nested comments.  While #if 0/#endif does the trick,
there is no rational reason (from a standards point of vierw) for
traditional comments to NOT be nestable other than laziness.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]