You could also use inline functions eg. { T p; T complex_pre() { } T complex_post() { } for( p = complex_pre(); p != null; p = complex_post()) { ..body.. } } Regan