I’m a teaching assistant for an introductory assembly language course this term. Specifically, it’s SPARC assembly. One of my favourite things about SPARC assembly is that the assembler does a terrible job of offering any sort of macro features. This may not sound like much of a benefit, but the benefit is that we get the students to use m4 for their macro needs. Hence, we’ve already built in to them the pipeline of running it through m4 and then assembling the code.

Anyway, I’ve been biding my time and biting my tongue for a while, saying “oh yes you can do crazy stuff in m4 like loops, but don’t worry about that. We won’t be doing any of that.” However, today I was talking a bit more about macros and how macros can invoke other macros, and their eyes lit up like Christmas trees.

So next lab I’m planning on breaking into it a little bit. I expect I’ll have a lot more stuff to talk about, but if I have time, I’ll talk about m4 and how it’s Turing-complete and maybe guage them for interest in non-imperative programming languages.

Can m4 be a gateway drug to functional programming?

Advertisements