The latest Oberon language definition by NW that I have found is Revision 1.10.2013 / 3.5.2016 (see http://people.inf.ethz.ch/wirth/Oberon/Oberon07.Report.pdf). It does have a numeric CASE statement. My interpretation of what might have happened is this: In Oberon07 the numeric CASE had been dropped, but later it has been reintroduced but the ELSE has been forgotten. To me, a numeric CASE without an ELSE is pointless. The compiler needs to emit a range check anyway for generating a TRAP if there is no ELSE. The ELSE part comes (almost) for free. If the ELSE check is done outside the CASE, it is actually done twice. In contrast to some postings, by the way, the labels are not forced to start with 0 and they can also be negative (by specifying a negative named constant). In a real implementation, it would be much simpler to allow any ConstantExpr of appropriate result type, though. My conclusion so far is: If the numeric CASE is not implemented but only specified, it should not be taken literally. - Josef
On Fri, Feb 16, 2018, at 10:42 AM, Josef Templ wrote:
In contrast to some postings, by the way, the labels are not forced to start with 0 and they can also be negative (by specifying a negative named constant). In a real implementation, it would be much simpler to allow any ConstantExpr of appropriate result type, though.
Before the type-case form, labels were only integer | string in the grammar, or even only integer long before (in 2008 report). The absence of qualident precluded the use of named constants. Later qualident was added but only for the type discrimination, I think. The fact that labels start from 0 is explicitly written here: http://people.inf.ethz.ch/wirth/Oberon/Oberon07.pdf I don't think the removal of ELSE was unintentional, also original Pascal didn't have it.
On Fri, 16 Feb 2018 10:42:41 +0100 Josef Templ <josef.templ@gmail.com> wrote:
The latest Oberon language definition by NW that I have found is Revision 1.10.2013 / 3.5.2016 (see http://people.inf.ethz.ch/wirth/Oberon/Oberon07.Report.pdf).
It does have a numeric CASE statement.
Hi, Trying to catch up with this rather interesting post. Let me quote the code part of the `ORP' (4.4.2017) parser. ... ELSIF sym = ORS.case THEN ORS.Get(sym); IF sym = ORS.ident THEN qualident(obj); orgtype := obj.type; IF (orgtype.form = ORB.Pointer) OR (orgtype.form = ORB.Record) & (obj.class = ORB.Par) THEN Check(ORS.of, "OF expected"); TypeCase(obj, x); L0 := 0; WHILE sym = ORS.bar DO ORS.Get(sym); ORG.FJump(L0); ORG.Fixup(x); obj.type := orgtype; TypeCase(obj, x) END ; ORG.Fixup(x); ORG.FixLink(L0); obj.type := orgtype ELSE ORS.Mark("numeric case not implemented"); ... Numeric CASE seems really not implemented while `Oberon.Report-07' claims it is part of the language. I wish to know, if it was left out on purpose, possibly expected to be included in future revisions? Many thanks. -- Tomas Kral <thomas.kral@email.cz>
participants (3)
-
Diego Sardina -
Josef Templ -
Tomas Kral