home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / cplus / 2100 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  2.7 KB

  1. Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!mcsun!sun4nl!ruuinf!prisma.cv.ruu.nl!rvloon
  2. From: rvloon@cv.ruu.nl (Ronald van Loon)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: stringize preprocessing operator?
  5. Message-ID: <1993Jan21.145220.343@cv.ruu.nl>
  6. Date: 21 Jan 93 14:52:20 GMT
  7. References: <1993Jan18.192417.16933@digi.lonestar.org> <1993Jan19.181741.4779@taumet.com> <KRISS.93Jan21114643@trot.ibp.fr>
  8. Sender: usenet@cv.ruu.nl (Usenet Network)
  9. Organization: University of Utrecht, 3D Computer Vision Research Group
  10. Lines: 50
  11. Originator: rvloon@triton.cv.ruu.nl
  12. Nntp-Posting-Host: triton.cv.ruu.nl
  13.  
  14. In <KRISS.93Jan21114643@trot.ibp.fr> kriss@trot.ibp.fr (Christophe GROSJEAN) writes:
  15.  
  16. |"In article <1993Jan19.181741.4779@taumet.com> steve@taumet.com (Steve Clamage) writes:
  17. |"
  18. |"   Preprocessing in C++ is supposed to be the same as in Standard C
  19. |"   (except for // comments).  The ARM tries to say that, and the
  20. |"   C++ Standard will make it so.
  21. |"
  22. |"By the way, does anybody ever thought of the problems that occurs between
  23. |"preprocessors macros and templates.
  24. |"
  25. |"If I define a macro that use *a type* as an argument, whenever I use
  26. |"templates with multiple arguments in this macro, I have a problem :
  27. |"the problem is coma. It's the *only* valid argument separator for
  28. |"macros !
  29. |"Isn't it time to betterize the standard C++ preprocessor.
  30. |"Usefull features would be :
  31. |"    1 - changing separator for a macro
  32. |"    2 - enable macro overloading,    you can do it with functions,
  33. |"    why not with macros ? I don't ask for typed arguments,
  34. |"    (it would be stupid), but for the number of arguments.
  35. |"    3 - compile time vars, in order to save and restore contexts in macro
  36. |"    it could be something like #define inside macros.
  37. |"    this last one would be *very* usefull, but I think it's a dream.
  38. |"
  39. |"However, the other 2 enhancement, seems sensible.
  40. |"Yet, there is another way to bypass my problem : taking care of templates
  41. |"*before* macros. If this were the case, my problem wouldn't occurs
  42. |"any more.
  43.  
  44. I have successfully used the following trick:
  45.  
  46. #define COMMA ,
  47.  
  48. #define f(a,b) template a harry(List ## b);
  49.  
  50. f(<class some_class COMMA class some_class2>, 
  51.   < some_class COMMA some_class2 >);
  52.  
  53. (the macro isn't realistic, but it assumes a List class somewhere that can be
  54.  instantiated through this macro)
  55.  
  56. This works, because the comma is expanded AFTER 'f' is expanded. It doesn't
  57. work, however, if 'f' calls other macros that use arguments passed to your
  58. first macro.
  59. -- 
  60. Ronald van Loon     | Consider this: In the United States, an automobile is
  61. (rvloon@cv.ruu.nl)  | stolen EVERY 14.7 SECONDS. 
  62. 3DCV Group, Utrecht |   If that statistic scares you, think how we felt when we 
  63. The Netherlands     | made it up. - Dave Barry, "CHRISTMAS BUYERS GUIDE"
  64.