[Oberon] System.Directory options
Andreas Pirklbauer
andreas_pirklbauer at yahoo.com
Wed Nov 1 20:58:15 CET 2017
> On a more general basis, the character "!" was clearly a
> hack. It was meant an as exception to otherwise clean rules.
> Apparently, clean rules led to restrictions, and the real
> life prevailed.
Yes, it’s always been a hack - and one that got worse over
time, not better, unfortunately. Back in 1988 there was in
fact no ! option. Then an option stored in a global variable
diroptions was added pretty soon by someone. See the 1992
and 2005 Editions of the book Project Oberon, which state:
PROCEDURE List(..);
...
BEGIN
...
IF diroption = "d” THEN (*<--- global variable*)
Kernel.GetSector(adr, hp);
Texts.WriteString(W, " “);
Texts.WriteDate(W, hp.time, hp.date);
Texts.WriteInt(W,
LONG(hp.aleng)*FileDir.SectorSize
+ hp.bleng - FileDir.HeaderSize, 8)
END
...
END List;
PROCEDURE Directory*;
...
BEGIN
...
i := 0;
WHILE (ch > " ") & (ch # "/") DO
pat[i] := ch; INC(i); Texts.Read(R, ch)
END;
pat[i] := 0X;
IF ch = "/“ THEN
Texts.Read(R, diroption) (*<—global variable*)
ELSE diroption := 0X
END;
...
END Directory;
So the option was a variable ‘diroptions’ and not
yet packed into the pattern ‘pat'.
Then suddenly someone had the idea to pack the ! option
into the pattern itself (which is still the current
status quo), thereby eliminating the global variable
diroptions. Why was it done this way? I have no idea!
The clean solution would be:
1) to return to the original 1992/2005 approach with
a separate variable diroptions.
2) to generalize procedure System.GetArg such that
also accepts Unix style parameters -a, -b ..
All this exists in various places and in various
forms, e.g. regular expression parsers in Native
Oberon. It just isn’t part of Original Oberon -
which is a pity.
-AP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171101/fc7fde2d/attachment.html>
More information about the Oberon
mailing list