[Oberon] Why macros were not implemented in oberon language?
joerg.straube at iaeth.ch
Sat Jul 5 13:01:54 CEST 2014
If you really want that use macro expansion (although not recommended due to possible pifalls), use the C preprocessor on an Oberon file. Let's assume you have a Unix box with C and Oberon installed, you can run the C preprocessor directly without calling the C compiler afterwards by entering
> Am 05.07.2014 um 12:03 schrieb <oberon at moravcik.info>:
> I am using oberon language and I think I will keep using it because compared to C language oberon is higher level language therefore for me (as a human) oberon is a better language to understand.
> 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?
> There are builtin procedures like INC(n) or DEC(n) in oberon. If you ask yourself why there are such procedures if you can express the same thing by
> writing n := n + 1 and n := n - 1 it is obvious to me that those two procedures were implemented because on machine level
> incrementing/decrementing can usually be done more efficiently by choosing different processor instructions and therefore the program runs faster.
> But now consider this.
> 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
> write procedure like:
> PROCEDURE RepeatingPart;
> IF i < 30 THEN n := n + 10 END
> END RepeatingPart;
> and call this procedure the same way you are calling a macro.
> Your program gets more readable by human but computer has to call every time one more procedure which makes it run little bit more longer.
> Therefore omitting macros and replacing them with proper procedures is not perfect program optimisation when program speed is an issue while at the same time letting INC,DEC inside oberon is considered a optimisation effort?
> Maybe I am wrong and miss some point here. Someone could explain to me why there are no macros in Oberon?
> Or even better someone of you at ETH could ask professor Wirth directly why he chose not to implement macros in his oberon?
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2334 bytes
Desc: not available
Url : https://lists.inf.ethz.ch/pipermail/oberon/attachments/20140705/3c133756/attachment.bin
More information about the Oberon