[Oberon] Re. CASE statement error
easlab at absamail.co.za
easlab at absamail.co.za
Mon Nov 7 20:39:59 CET 2005
Necati Ecevit wrote:
> The following code gives the error: "case range too large" in Oberon and
> traps in Bluebottle/Aos with PC0.Compile.
>
> PROCEDURE TestCase;
> VAR x: INTEGER;
> BEGIN
> x:=500;
> CASE x OF
> 1 :
> | 100 :
> | 514 : (* err:209 case range too large *)
> | -413 : (* err:209 case range too large *)
> ELSE
> END;
>
> END TestCase;
>
> According to OberonReport.html case labels must be integer or char type.
> When they are integer, min/max value of a label should be min/max of
> integer type.
>
> This error does not occur in Component Pascal (Blackbox/ Oberon) and
> OO2C.
>
> Is this a bug ?
A common way of implementing the 'case' construct is by an indexed
jump table. So:
CASE x OF
84: do84;
85: do85;
89: do89;
simplistically needs object code [of fixed/known piece-sizes]
jumpto case 84
jumpto case 85
jumpto invalid
jumpto invalid
jumpto invalid
jumpto case 89
Since the' range' in this example is 89 - 84 +1, we need 6 code-stretches
to implement the construct.
Using your range would need 514 + 413 + 1 jump entries to impliment
a mere 4 cases. Ie. the jump table is very sparse/uneconomical.
Hence it's a good reason to give an error - to tell you to use IF/ELSE
instead. NB it's not the max/min of the cases, but the range, since the
jump table uses an offset. I speculate that cases: 888, 890 ...899
would not give an error ?
== Chris Glur.
PS. Personally I think the only type of speed that matters is that
which saves humans time/effort [ie. human interface is all important]
but some people like to follow these speed competitions:-
URL: http://shootout.alioth.debian.org/benchmark.php?test=all&lang=a\
ll&sort=fullcpu>
Date: Mon, 7 Nov 2005 08:06:11 -0500 (EST)
Can you manipulate the
multipliers and weights to make your favourite language the fastest
programming language in the Shootout?
And remember, languages that implement more benchmarks will move to
the top of the list, and those with many missing benchmarks (No
Program, Error, Timeout) will stay at the bottom!
And remember, "For every complex problem, there is a solution that is
simple, neat, and wrong."
language score missing
D Digital Mars[5] 76.503
Forth GForth[6] 75.813
C Intel[7] 75.655
Lua[8] 68.091
Haskell GHC[9] 66.762
Pascal Free Pascal[10] 66.124 <----- ?!?
SML MLton[11] 65.132
OCaml[12] 63.514
C gcc[13] 62.786
OCaml (bytecode)[14] 55.492
Python[15] 55.143
C# Mono[16] 54.962
Ada 95 GNAT[17] 53.694
Java JDK -server[18] 50.224
Lisp CMUCL[19] 48.794
Dylan Gwydion[20] 44.126
Lisp SBCL[21] 43.415
Clean[22] 42.428
Oberon-2 OO2C[23] 38.458 <----- ?!?
Perl[24] 37.435
Tcl[25] 35.866
C++ g++[26] 34.7710
SML SML/NJ[27] 33.519
Erlang[28] 31.959
Fortran GNU[29] 31.219
Scheme Chicken[30] 30.838
C++ Intel[31] 25.6011
PHP[32] 23.9210
JavaScript SpiderMonkey[33] 23.0711
Ruby[34] 22.828
S-Lang[35] 22.1910
Fortran Intel[36] 16.1413
Rexx Regina[37] 4.1113
!! amazing oberon slower than Java; is it running on a virtual
machine a la P-code interpreter ?
More information about the Oberon
mailing list