[Oberon] Removing WITH.
peter at easthope.ca
peter at easthope.ca
Sun Dec 31 04:01:01 CET 2023
Hi,
This is from Oberon.Mail.Mod in A2.
PROCEDURE Seek(R: ListRiders.Rider; key: SIGNED32);
BEGIN
WITH R: Rider DO
R.key := key; R.pos := 0; R.sortPos := 0;
WHILE (R.pos < noMsgs) & (msgs[R.pos].pos # key) DO
INC(R.pos)
END;
IF R.pos >= noMsgs THEN
R.key := -1; R.pos := -1; R.sortPos := -1; R.eol := TRUE;
RETURN
END;
IF R.sort # NIL THEN
WHILE msgs[R.sort[R.sortPos]].pos # key DO
INC(R.sortPos)
END
END;
R.d(ListRiders.Int).i := R.pos
END
END Seek;
PROCEDURE Seek(R: ListRiders.Rider; key: SIGNED32);
BEGIN
R(Rider).key := key; R(Rider).pos := 0; R(Rider).sortPos := 0;
WHILE (R(Rider).pos < noMsgs) & (msgs[R(Rider).pos].pos # key) DO
INC(R(Rider).pos)
END;
IF R(Rider).pos >= noMsgs THEN
R(Rider).key := -1; R(Rider).pos := -1; R(Rider).sortPos := -1; R(Rider).eol := TRUE
ELSE
IF R(Rider).sort # NIL THEN
WHILE msgs[R(Rider).sort[R(Rider).sortPos]].pos # key DO
INC(R(Rider).sortPos)
END
END;
R(Rider).d(ListRiders.Int).i := R(Rider).pos
END
END Seek;
Also took the opportunity to remove the non-terminal RETURN.
Is there a better alternative to remove WITH?
Thx, ... P.L.
--
VoIP: +1 604 670 0140
work: https://en.wikibooks.org/wiki/User:PeterEasthope
More information about the Oberon
mailing list