[Oberon] Coding practice [Was: Re: Hennessy.Mod 64kB limit]
Jörg
joerg.straube at iaeth.ch
Wed Feb 19 09:28:32 CET 2020
A word on why I use multi-statement lines:
I mostly code along these two rules, if possible
1) to grasp the idea of a procedure it has to fit on a page. I mean you should not have to scroll to know whats going on.
2) Logical things should stay together
There are always exceptions and I decide on a per case basis whether I start a new line or not.
To explain what I mean: before entering a loop you normally have to initialize things.
If possible and not too complicated, I put all initializations on the same line.
Instead of
i := 0;
j := 345;
quit := FALSE;
REPEAT
...
I write
i := 0; j := 345; quit := FALSE;
REPEAT
...
When I have a short loop (eg searching for an object) I put everything on one line
Instead of
i := 0;
WHILE s[i] # 0X DO
i := i + 1
END;
I write
i := 0; WHILE s[i] # 0X DO INC(i) END;
or a little longer but (in my point of view) still readable.
s := topscope; WHILE (s # NIL) & (s.name # “SYSTEM“) DO s := s.next END;
Or
IF a[i] > a[i+1] THEN temp := a[i]; a[i] := a[i+1]; a[i+1] := temp END;
For me, a line is more like a “logical block“ instead of “one statement“.
I don‘t force anybody to do it the same.
br
Jörg
>> Am 18.02.2020 um 18:45 schrieb August Karlstrom <fusionfile at gmail.com>:
>
>> On 2020-02-18 17:26, Skulski, Wojciech wrote:
>> I am not questioning the code. I am questioning the coding practice:
>> avoiding any comments and writing bit masks explicitly in hex.
> I'm also a bit curious about the practice of putting several statement on the same line. This is something I have not seen in other languages. Is this simply "the Swiss way" of saving lines? To me it makes the logic harder to follow.
>
> -- August
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
More information about the Oberon
mailing list