4 ms·
Going back to the dark ages of assembly language, they implemented text macros to ease the programming burden. This worked at a text character level, with passe
by RNeff 8y ago
Going back to the dark ages of assembly language, they implemented text macros to ease the programming burden. This worked at a text character level, with passed parameter strings merged into defined text strings. This worked well most of the time. Debugging them was a challenge. Text macros were part of C and C++ and other languages. You could write very clever things, like faking isomorphism in pure C.
Algorithm textbooks, like Knuth's books, usually use pseudo-code for their examples, and can be considered 'generics'. I don't think Knuth's books are controversial.There are a number of attempts to re implement textbook algorithms into standard macro or generic packages.
Generics are an attempt to add semantics and checking to the macro text substitution process. Expanding the generic body in the context of the full compiler finds lots of errors.
Most of my generic work was with Ada(83). The main problem we found was there needed to be a way to define constraints on the type(s) that were passed in as parameters. Types may require an equality, less than, increment, or null for the algorithm to work correctly.
Another problem with both macro and generic approaches is the expansion will create a lot of code, not all of which will be used. A generic might create 50 to 100 methods, but only a handful will be used by the program. We talked about some way to specify which methods the program would use to restrict the code generated. (Obviously this feature would require computing the transitive closure of internal method calls)
The end goal is that all of the algorithms taught in CS classes would be directly available in my favorite programming language and environment. This does not seem to be controversial.