[Oberon] NW programming style

Jörg joerg.straube at iaeth.ch
Tue Jul 12 14:35:17 CEST 2016


Srinivas

That’s purely a matter of personal taste.
I personally put "short" things building one logical block on one line.

Eg.
  len := 0; WHILE s[len] # 0X DO INC(len) END;

These statements calculate the length "len" of the string "s" and build
logically one entity.
But you could format this block as follows:

  len := 0;
  WHILE s[len] # 0X DO
    INC(len)
  END;

Or very uncommon as follows:
  len := 0;
  WHILE s[len] # 0X
    DO
      INC(len)
    END;

Some of my "rules":
- When there is a logical block consisting of few statements taking less
  than let's say 60 characters, I put it on one line.
- I almost never put statements on the same line after a BEGIN.
- If not all statements of a THEN or ELSE clause fit on one line, I will
  use a line break after the THEN or ELSE.
- I don't like this type of construct (long IF, short ELSE)
  IF p = NIL THEN
    (* a huge bunch
       of statements
       doing this
       and that
       taking up
       several
       lines or
       even
       several
       pages
      *)
   ELSE Error(30)
   END

I rather rewrite this to
  IF p # NIL THEN Error(30)
  ELSE
    (* a huge bunch
       of statements
       doing this
       and that
       taking up
       several
       lines or
       even
       several
       pages
      *)
   END

But all these rules I made up for me, might not be applicable to other
people.

Jörg

-----Original Message-----
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Srinivas
Nayak
Sent: Dienstag, 12. Juli 2016 03:53
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] NW programming style

One thing I noticed, we put a couple of Oberon statements in a single
line...
Does this have any special significance?
I mean, is it that, the statements that are put in a single line
are somehow very closely related (logically) than other statements in other
lines?


With thanks and best regards,

Yours sincerely,
Srinivas Nayak

Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.in/

On 07/11/2016 11:43 PM, Bob Walkden wrote:
>> -----Original Message-----
>> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
>> Richard Hable
>>
>> Am 2016-07-11 um 17:13 schrieb Skulski, Wojciech:
>>
>>> I was always amused by NW advocating high level programming, using
>>> named constants rather than hard coding the numbers, etc. And then in
>>> his published book Project Oberon the reader can enjoy seeing "1",
>>> "2", and "3" meaning mouse clicks left, middle, and right. Which is
>>> the exact opposite of the principles NW was teaching.
>>
>> I don't think the master of simplicity ever advocated using named
> constants
>> in cases like this. It is not difficult to count to three when looking at
> the
>> mouse keys, and it wouldn't be possible to change the number assignment
>> anyhow without breaking compatibility to central Oberon System modules.
>>
>>> The grad students then cleaned the code in their Unix/Linux/Windows
>>> ports of Project Oberon. They used ML, MM, MR meaning mouse left,
>>
>> Students often exaggerate when applying the principles of their master.
:)
>
> ML, MM and MR aren't much better than 1, 2 and 3 anyway, since they refer
to
> the physical position of the buttons rather than to the semantics. The
> semantics of the mouse should also include the chords.
>
> B
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>
--
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