I found that some tool such as Noweb doesn’t support macro.
I want to know what are the advantages and disadvantages of macro in literate programming?
I found that some tool such as Noweb doesn’t support macro. I want to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’ll assume that by “macro” you mean having the LP tool do “macro-substitution” like the C preprocessor and most assemblers.
Macro substitution is “syntactic sugar”. It’s a way to write a single symbol that stands for lots of similar details. Hence the term “macro”: It was “macro-programming”, writing at a higher level of abstraction.
This is what we did in the olden days when we didn’t have object-oriented programming to provide easily-accessible layers of abstraction.
It was — technically — possible to have layers of abstraction and macro-style programming in C using just function calls. The pre-processor “macro” programming isn’t necessary. For example, we used to define inline functions as a preprocessor “macro” to hand-optimize our code. That’s because the C compiler didn’t optimize well in the early days.
Now that we have OO programming, the macro capabilities of more primitive programming languages aren’t needed.
The Literate Programming macro feature was used in non-OO languages (like C and Pascal) to create class-like capabilities, and inheritance-like capabilities at the LP level.
There’s no point in that. Just define proper classes and use proper inheritance.