[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

A Macro for Steppers



Last night I defined something similar in Smalltalk.  

STPREXPR forEach: [:val {TYPE} | body]

translates to:

for (SPTR(Stepper) LoopStpr = STPREXPR;
	LoopStpr ->hasValue();
	LoopStpr ->step()) {
    TYPE val = CAST(TYPE,LoopStpr->fetch());
    body;
}

This can translate to the equivalent while loop.  This covers most
uses.  I can also have it translate to any macro you like.  Note that
expression above creates the stepper in the STPREXPR.

dean