home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17851 < prev    next >
Encoding:
Text File  |  1992-12-12  |  3.5 KB  |  64 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!spool.mu.edu!umn.edu!csus.edu!netcom.com!erc
  3. From: erc@netcom.com (Eric Smith)
  4. Subject: Re: Criticisms Wanted:Callbacks&Runtime methods
  5. Message-ID: <1992Dec12.124839.11240@netcom.com>
  6. Keywords: callbacks C++ Runtime methods
  7. Organization: Netcom - Online Communication Services (408 241-9760 guest)
  8. References: <1gc6fhINN6nr@tamsun.tamu.edu>
  9. Date: Sat, 12 Dec 1992 12:48:39 GMT
  10. Lines: 52
  11.  
  12. In article <1gc6fhINN6nr@tamsun.tamu.edu> pinky@tamu.edu (The Man Behind The Curtain) writes:
  13. >A macro language would be incredibly useful, but that'd be dreaming.
  14.  
  15. I've got that on the back burner.  My parser, which contains its own
  16. preprocessor, already has some extra macro features I'm using, and I'm
  17. planning to release a very powerful extended C++ preprocessor in the
  18. future, which will evolve from it.  I'm using it right now as a
  19. preprocessor even with C++ compilers that don't have a separate
  20. preprocessor, just adding mine as an extra initial stage in the
  21. makefile.  But it doesn't take much extra time because doing the
  22. preprocessing in advance reduces the workload on the C++ compiler,
  23. thereby making it faster.
  24.  
  25. The extra feature I find most useful right now is being able to define
  26. new macros from within a macro, using the outer macro's arguments to
  27. change the definition of the inner macro, and its name, etc.  This in
  28. fact gives me some of the most important advantages of templates when
  29. using a C++ compiler that doesn't support templates.
  30.  
  31. I'm also experimenting with supporting macro scope.  I plan to support
  32. both old style macros, for which you use #define, and my new style
  33. macros, for which you would use a different word such as #macro,
  34. although right now it's just #m.  (But it's trivial to change.)
  35. Anyway, for scope, my new style macros have the scope of the block they
  36. are defined in, and old style macros still have to-end-of-file scope.
  37.  
  38. Using block scope for macros requires more parsing than most C/C++
  39. preprocessors do, and in fact mine completely parses and error checks
  40. the whole program while preprocessing it.  But fortunately I use a
  41. very fast parsing algorithm, so it doesn't really waste much time
  42. duplicating the compiler's efforts.  It also makes it easier to
  43. "pulverize" the code for compilers that can't handle complicated
  44. code due to compiler bugs.
  45.  
  46. Old style macros are effectively one line of code each, with additional
  47. lines being appended at the end of that line.  That prohibits defining
  48. new macros from inside a macro, because a macro definition has to be at
  49. the start of a line.  So my new style macros allow multiple lines
  50. without the backslash at the end of each line, but require a
  51. termination token for the whole macro.  So macro definitions inside
  52. macros are trivial with my new style macros.  (Don't confuse macro
  53. calls inside macros with macro definitions inside macros.  It's the
  54. definitions, not the calls, that give template-like power.)  I also
  55. allow new style macro call arguments to follow the macro name directly,
  56. without parentheses.  That could be considered a 2nd new style,
  57. although my parser considers it a minor variation of my first new
  58. style.  In that 2nd new style, the macro arguments are delimited not
  59. with commas and parentheses, but differently in several ways, with the
  60. aim of making them fit neatly in tables, usually with one macro call
  61. per line of the table.  A neatly tabulated table is often the best way
  62. to code a set of rules and exceptions, so I use that format a lot in
  63. the source code of my C++ parser.
  64.