[Oberon] Why macros were not implemented in oberon language?

Paul Reed paulreed at paddedcell.com
Sat Jul 5 12:42:54 CEST 2014


Dear z.

> But it seems to me that even oberon language is not perfect. Sometimes I
> am asking myself why prof. Wirth did not implement macros in his language?
...
> If you have in your program some repeating code like "IF i < 30 THEN n :=
> n + 10 END" and this code repeats many times you can obviously...

Actually, it seems here you are making a case for procedure inlining,
rather than macros.

It is worth reading Prof. Wirth's books carefully to discern his views on
language design, "optimisation" (of which the above is one), and
extensibility, and learn from his pragmatic experience.  In particular,
Programming in Oberon and Compiler Construction are available as PDFs on
his website and are a very rewarding cover-to-cover read in comparison to
many much thicker tomes.  I think many of your questions may be best
answered this way.

I remember reading Compiler construction and thinking that the following
passage (in section 5.1 in
http://www.inf.ethz.ch/personal/wirth/CompilerConstruction/CompilerConstruction1.pdf)
seems to make the case against macros and operator overloading:

"Ultimately, the basic idea behind every language is that it should serve
as a means for communication. This means that partners must use and
understand the same language. Promoting the ease by which a language can
be modified and extended may therefore be rather counterproductive."

I have extensive experience in commercial situations trying to maintain
code that other people have written (in a variety of languages), and I
definitely concur with the above observation!

Since I read it, I've noticed that I've certainly not been too bothered
about macros because the times they could be used to good effect are few,
compared with the enormous possibilities for abuse (and the increase in
complexity of the tools and environment).  Nowadays, I am happy to accept
less fancy features in my tools because there's less stuff to "get in my
way".

Hope that helps,
Paul





More information about the Oberon mailing list