|pre-processing firstname.lastname@example.org (Sukru Cinar) (1999-04-09)|
|From:||Sukru Cinar <email@example.com>|
|Date:||9 Apr 1999 14:16:24 -0400|
Hello, I Have Recently Been Working On A Cpp-Like Preprocessor. But I Have
A Problem With Recursively Defined Macros. Such As
#define N N+5
I see that cpp doesn't expand these kinds of recursive expressions more
than once. the problem is, if you expand the text only once, than you
cannot use expressions including macro invocations as parameters to a
macro. this is pretty ugly. the preprocessor looses most of its
functionality. if you allow expansion of strings every time after a macro
expansion occurs, then the infinite loop thing emerges. checking all the
strings that are result of an expansion against a recursion seems to me
costly.( what if the recursion is a deep one ? )
Does anybody have an idea about a good solution to this? Is this situation
worth considering? I Mean, Are There Any Real Life Cases That Recursive
Macros May Be Useful?
Thanx For Any Help.
[In a weak macro language like cpp without conditional macro expansion
recursion isn't useful because it always is an infinite explosion. In a
more complete macro language like TCL or Trac, recursive macros are
very useful because that's how you do macro-time iteration. -John]
Return to the
Search the comp.compilers archives again.