Thread: design question: opinion

  1. #1
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001

    design question: opinion

    I'm writing a preprocessor, and I've come across a problem.

    If a macro is used in an expansion of itself, it won't be processed. So somehow, I've got to check this in the expansion. This can lead to two models:

    1) Total Expansion

    The function that expands the macro also fully expands the result of the macros. This way the entire expansion progress can be kept in a single function stack..

    2) Gradual Expansion

    The function that expands the macro does a basic expansion job, pushes the macro expanded onto what is pretty much a global stack (inside the preprocessor structure), and leaves a token at the end of the expanded macro ordering the preprocessor to pop off a level of nesting.

    The gradual expansion might actually be easier to write, but I'd like to know what any experienced coders think about the cleaness and simplicity of each option. Maybe even suggest something else.. I'd like to make it possible to change things without everything blowing up, btw.

    So, tia for everybody who takes a look.

    edit: a fun example

    #define x(y) z(y)
    #define z(y) x(y)

    x(y) should process to x(y), and z(y) should process to z(y) (very useful, no?)
    Last edited by ggs; 01-28-2003 at 03:19 PM.
    .sect signature

  2. #2
    Registered User
    Join Date
    Nov 2002
    I do not have a compiler handy to test, but wouldn't this just recurse to infinity?

  3. #3
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    the problem was to prevent infinite recursion. i just decided to take the easy way out, so this thread can die..
    .sect signature

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about engine design.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 01-29-2008, 10:53 AM
  2. question about class design and overloading
    By l2u in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2007, 02:02 PM
  3. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  4. program design question
    By theroguechemist in forum C++ Programming
    Replies: 4
    Last Post: 03-02-2004, 08:45 PM
  5. database app design question
    By MPSoutine in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2003, 10:13 PM