From: Brian G. <br...@qu...> - 2003-04-19 01:21:00
|
>#macro visitChildren( $node) > > #foreach $n in $node.Children > $n.Text<br> #visitChildren( $n) > #end > >#end > >## ******************************************************** >## Call the code >## ******************************************************** > >#visitChildren( $rootNode) Of course this causes a stack overflow. You have written a recursive macro with no base case. It is equivalent to: public int screwMe(int n) { return screwMe(n-1); } In order to make recursive functions stop, you must reach a base case: public int factorial(n) { if (n < 0) throw new ArithmeticException("negative factorial"); else if (n == 0 || n == 1) return 1; else return n * factorial(n-1); } Do the same with your macro. There must be some way #visitChildren can expand to something that doesn't involve calling #visitChildren.... -- Brian Goetz Quiotix Corporation br...@qu... Tel: 650-843-1300 Fax: 650-324-8032 http://www.quiotix.com |