[fpc-pascal] Proper preprocessor?

denisgolovan denisgolovan at yandex.ru
Fri Jun 22 10:24:35 CEST 2018



> C was designed from the ground up with preprocessing. Pascal, and most newly
> designed languages, do not have preprocessing built-in. For good reason.

Well. I can't agree.
C macros are bolted on :). It's too alien for main part of language. No respect to captured variables, no operator priorities, parsing is hard, etc.
On the other hand, recent language Rust has macros nicely integrated in language itself and they plan to extend them in 2.0 version.
D language also has mixins. Let alone Lisp-dynamics derivatives.
Those macros help a lot in intensive meta programming (read writing interpreters/compilers/introspection heavy applications) and reduce total line count considerably.

Generics are rather limited in that respect. 
At least some construction should exist to instantiate those generics.
e.g. to create several public structs, interfaces, free functions (possibly instancing generics) in one go.

My personal way of doing stuff like that is "m4 -> pas/inc" conversion and triggering them in makefiles. 
Robust incremental pre-processing is quite affordable for make + m4 combination as well.
Again Rust macros being something in between C defines and m4 in terms of power are really pragmatic at times.

> Some cans are better left unopened. Or pandora's box is better left
> closed... (if you prefer mythological references ;) )

Again, different design philosophies lead to different design decisions.
Better less amount of code + more automatic consistence leading to more cryptic code (have a look at APL/J/... implementation) OR lots of boilerplate + less consistence, but much more readable for non-experts? 
What about refactoring price in both scenarios? Open source projects have a variety of opinions on that.

But I generally support FreePascal team in avoiding features they personally don't extensively use :)

-- 
Regards,
Denis Golovan



More information about the fpc-pascal mailing list