Reading (for next class): Section 6.1.2. Everything form "Boxing" (p. 228) on is optional.
You can invoke the C preprocessor on any file! For example, if we
have an SPL program stored in a.spl
, with some C preprocessor
commands, we can run
gcc -E - < a.spland the preprocessed code will be written to standard out.
The following is an SPL program to compute the greatest common divisor of two integers.
new mod := lambda a { ret := lambda b { ret := a - (a/b)*b; }; }; new gcd := lambda a { ret := lambda b { if (b = 0) { ret := a; } else { ret := gcd(b)( mod(a)(b) ); } }; }; write gcd(24)(42);
mod
above as a
function-like macro to do the same thing.
gcd
function
itself as a function-like macro?